### Configuration Object Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Provides an example of a configuration object used for initializing Raphtory. ```scala val config = ConfigFactory.parseString("raphtory.data.source.name = \"my_data_source\"") ``` -------------------------------- ### Graph Process Configuration Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html A complete example of configuring a graph processing step. ```scala val config = ConfigFactory.parseString("raphtory.graph.process { name = \"node_cleaning\" strategy = \"remove_duplicates\" memoryLimit = 8g }") ``` -------------------------------- ### Full Data Pipeline Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html An end-to-end example demonstrating the full data pipeline from loading to saving. ```scala raphtory.data("data_source_name").process("process_name").query("query_name").visualize("visualization_name").save("output_path") ``` -------------------------------- ### Graph Visualization Configuration Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html A complete example of configuring graph visualization. ```scala val config = ConfigFactory.parseString("raphtory.graph.visualization { layout.engine = \"gephi\" nodeLabel.fontSize = 10 export.resolution = 300 }") ``` -------------------------------- ### Graph Process Configuration Example with Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph process configuration with specific options. ```scala val config = ConfigFactory.parseString("raphtory.graph.process { name = \"node_cleaning\" strategy = \"remove_duplicates\" options { memoryLimit = 8g } }") ``` -------------------------------- ### Graph Query Configuration Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html A complete example of configuring a graph query. ```scala val config = ConfigFactory.parseString("raphtory.graph.query { name = \"find_shortest_path\" algorithm = \"dijkstra\" cacheResults = true }") ``` -------------------------------- ### Graph Output Path Configuration Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html A complete example of configuring the graph output path. ```scala val config = ConfigFactory.parseString("raphtory.graph.output { path = \"/graph/results\" format = \"parquet\" options.overwrite = true }") ``` -------------------------------- ### Graph Visualization Configuration Example with Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph visualization configuration with specific options. ```scala val config = ConfigFactory.parseString("raphtory.graph.visualization { layout.engine = \"gephi\" options { nodeLabel.fontSize = 10 } }") ``` -------------------------------- ### Run Raphtory Rust Benchmark Source: https://github.com/pometry/raphtory/blob/db_v4/raphtory-benchmark/readme.md Execute the Raphtory Rust benchmark. Ensure you have the correct file path and delimiter arguments. Use --download to get an example file. ```bash cargo run --release -- --download ``` ```bash cargo run --release -- --file-path ``` ```bash cargo run --release -- --file-path="/Users/1337/Documents/dev/Data/lotr.csv" --delimiter="," --from-column=0 --to-column=1 ``` -------------------------------- ### Graph Output Path Configuration Example with Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph output path configuration with specific options. ```scala val config = ConfigFactory.parseString("raphtory.graph.output { path = \"/graph/results\" options { format = \"parquet\" overwrite = true } }") ``` -------------------------------- ### Graph Process Configuration Example with Nested Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph process configuration with nested options. ```scala val config = ConfigFactory.parseString("raphtory.graph.process { name = \"node_cleaning\" strategy = \"remove_duplicates\" options { memoryLimit = 8g parallelism { level = 4 } } }") ``` -------------------------------- ### Graph Data Source Configuration Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html A complete example of configuring a graph data source. ```scala val config = ConfigFactory.parseString("raphtory.graph.source { name = \"my_graph_db\" connectionString = \"jdbc:neo4j://localhost:7687\" timeout = 30s }") ``` -------------------------------- ### Graph Query Configuration Example with Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph query configuration with specific options. ```scala val config = ConfigFactory.parseString("raphtory.graph.query { name = \"find_shortest_path\" algorithm = \"dijkstra\" options { cacheResults = true } }") ``` -------------------------------- ### Graph Data Source Configuration Example with Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph data source configuration with specific options. ```scala val config = ConfigFactory.parseString("raphtory.graph.source { name = \"my_graph_db\" connectionString = \"jdbc:neo4j://localhost:7687\" options { timeout = 30s } }") ``` -------------------------------- ### Data Visualization Setup Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Illustrates the setup for visualizing graph data. This might involve integrating with a visualization library. ```scala // Visualization setup code would go here println("Visualization setup code not provided.") ``` -------------------------------- ### Start Raphtory Server Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/getting-started/30_cli.md Starts the Raphtory GraphQL server with various configuration options. ```APIDOC ## Start Raphtory Server ### Description Starts the GraphQL server with specified configuration parameters. ### Method CLI Command ### Endpoint N/A ### Parameters #### Command Line Options - **-h, --help** (flag) - Show the help message and exit. - **--work-dir** (WORK_DIR) - The working directory for the server. - **--cache-capacity** (CACHE_CAPACITY) - The capacity of the cache. - **--cache-tti-seconds** (CACHE_TTI_SECONDS) - Cache time-to-idle in seconds. - **--log-level** (LOG_LEVEL) - The logging level (e.g., INFO, DEBUG). - **--tracing** (flag) - Enable tracing. - **--tracing-level** (TRACING_LEVEL) - Set the tracing level. Available options are: COMPLETE, ESSENTIAL, MINIMAL. - **--otlp-agent-host** (OTLP_AGENT_HOST) - OTLP agent host for tracing. - **--otlp-agent-port** (OTLP_AGENT_PORT) - OTLP agent port for tracing. - **--otlp-tracing-service-name** (OTLP_TRACING_SERVICE_NAME) - OTLP tracing service name. - **--auth-public-key** (AUTH_PUBLIC_KEY) - Public key for authentication. - **--auth-enabled-for-reads** (flag) - Enable authentication for read operations. - **--config-path** (CONFIG_PATH) - Optional path to a configuration file. - **--create-index** (flag) - Enable index creation. - **--port** (PORT) - The port for Raphtory to run on. Defaults to 1736. - **--timeout** (TIMEOUT) - Timeout for starting the server in milliseconds. Defaults to 180000ms. ### Tracing Levels - **COMPLETE**: Provides full traces for each query. - **ESSENTIAL**: Tracks key functions: addEdge, addEdges, deleteEdge, graph, updateGraph, addNode, node, nodes, edge, edges. - **MINIMAL**: Provides summary execution times. ### Request Example ```sh raphtory server --port 1736 --log-level INFO --tracing ``` ### Response Starts the Raphtory server and listens on the specified port. ``` -------------------------------- ### Run Neo4j Benchmark (Docker Setup) Source: https://github.com/pometry/raphtory/blob/db_v4/raphtory-benchmark/readme.md This command initiates the Docker setup for the Neo4j benchmark. After setup, it runs a `tail -f /dev/dull` command. To proceed, quit this process, then use `docker ps` to find the container name and `docker exec -it bash` to log in. Navigate to `/var/lib/neo4j/import/data2/` and run the benchmark script without Docker. ```bash python3 benchmark_driver.py -b neo ``` ```bash tail -f /dev/dull ``` ```bash docker ps ``` ```bash docker exec -it bash ``` ```bash cd /var/lib/neo4j/import/data2/ ``` ```bash python3 benchmark_driver.py -b neo --no-docker ``` -------------------------------- ### Graph Data Analysis Workflow Examples Source: https://github.com/pometry/raphtory/blob/db_v4/docs/assets/mascot64.txt Step-by-step examples of common graph data analysis workflows. ```scala // Example: Social network analysis workflow ``` -------------------------------- ### Install Documentation Build Dependencies Source: https://github.com/pometry/raphtory/blob/db_v4/CONTRIBUTING.md Installs Python dependencies required for building Raphtory documentation. ```bash sudo apt update.md && sudo apt install -y pandoc make python3-sphinx ``` ```bash cd docs && pip install -q -r requirements.txt ``` -------------------------------- ### Graph Output Path Configuration Example with Nested Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph output path configuration with nested options. ```scala val config = ConfigFactory.parseString("raphtory.graph.output { path = \"/graph/results\" options { format = \"parquet\" overwrite = true compression { codec = \"snappy\" } } }") ``` -------------------------------- ### Graph Visualization Configuration Example with Nested Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph visualization configuration with nested options. ```scala val config = ConfigFactory.parseString("raphtory.graph.visualization { layout.engine = \"gephi\" options { nodeLabel.fontSize = 10 export { format = \"png\" resolution = 300 } } }") ``` -------------------------------- ### Chaining Graph Operations Configuration Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html A complete example of configuring chaining graph operations. ```scala val config = ConfigFactory.parseString("raphtory.graph.chaining { maxDepth = 5 options.intermediateResults = \"save\" }") ``` -------------------------------- ### Chaining Graph Operations Configuration Example with Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing chaining graph operations configuration with specific options. ```scala val config = ConfigFactory.parseString("raphtory.graph.chaining { maxDepth = 5 options { intermediateResults = \"save\" } }") ``` -------------------------------- ### Graph Query Configuration Example with Nested Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph query configuration with nested options. ```scala val config = ConfigFactory.parseString("raphtory.graph.query { name = \"find_shortest_path\" algorithm = \"dijkstra\" options { cacheResults = true timeout { duration = 1m } } }") ``` -------------------------------- ### Start Raphtory GraphServer and Client Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/getting-started/20_intro.md Initializes a GraphServer with a specified working directory, starts it, obtains a client, and sends a graph to the server. Ensure the graph data and directory are correctly set up. ```python server = graphql.GraphServer(".idea/my-test/graphs") client = server.start().get_client() client.send_graph("OBS-graph", g, overwrite=True) ``` -------------------------------- ### Graph Data Source Configuration Example with Nested Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph data source configuration with nested options. ```scala val config = ConfigFactory.parseString("raphtory.graph.source { name = \"my_graph_db\" connectionString = \"jdbc:neo4j://localhost:7687\" options { timeout = 30s retry { count = 3 delay = 5s } } }") ``` -------------------------------- ### Querying Node Interactions Before, After, and Across Time Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/views/2_time.md This example demonstrates querying a node's interactions across the full dataset, before a specific epoch time, and after a specific datetime string. It uses `before()` on the graph and `after()` on the node, highlighting potential differences in outcomes. It also shows how to access the start and end times of the resulting views. ```Python import pandas as pd from raphtory import Graph from datetime import datetime edges_df = pd.read_csv( "../data/OBS_data.txt", sep="\t", header=0, usecols=[0, 1, 2, 3, 4], parse_dates=[0] ) edges_df["DateTime"] = pd.to_datetime(edges_df["DateTime"]) edges_df.dropna(axis=0, inplace=True) edges_df["Weight"] = edges_df["Category"].apply( lambda c: 1 if (c == "Affiliative") else (-1 if (c == "Agonistic") else 0) ) g = Graph() g.load_edges( data=edges_df, src="Actor", dst="Recipient", time="DateTime", layer_col="Behavior", properties=["Weight"], ) v = g.node("LOME") print(f"Across the full dataset {v.name} interacted with {v.degree()} other monkeys.") v_before = g.before(1560428239000).node("LOME") # 13/06/2019 12:17:19 as epoch print( f"Between {v_before.start} and {v_before.end.dt}, {v_before.name} interacted with {v_before.degree()} other monkeys." ) v_after = g.node("LOME").after("2019-06-30 9:07:31") print( f"Between {v_after.start.dt} and {v_after.end}, {v_after.name} interacted with {v_after.degree()} other monkeys." ) ``` -------------------------------- ### Install Raphtory with Pip (Python) Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/getting-started/10_installation.md Use this command to install the Raphtory Python package. ```bash pip install raphtory ``` -------------------------------- ### Install Python Test Dependencies Source: https://github.com/pometry/raphtory/blob/db_v4/CONTRIBUTING.md Installs the necessary Python dependencies for running tests. ```bash python -m pip install -q pytest networkx numpy seaborn pandas nbmake pytest-xdist matplotlib ``` -------------------------------- ### Alerting and Notifications Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example related to setting up alerts or notifications. ```scala val alertConfig = ConfigFactory.parseString("raphtory.alert.email = \"admin@example.com\"") ``` -------------------------------- ### Time-Varying Graph Analysis Setup Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Provides setup code for analyzing graphs that change over time. This requires handling temporal data. ```scala // Code for handling temporal graph data would be specific to the library println("Time-varying graph analysis setup not shown.") ``` -------------------------------- ### Graph Error Handling Configuration Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html A complete example of configuring graph error handling. ```scala val config = ConfigFactory.parseString("raphtory.graph.error { handling.strategy = \"log_and_continue\" options.logLevel = \"WARN\" }") ``` -------------------------------- ### Start Raphtory GraphQL Server in Python Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/graphql/2_run-server.md Starts a GraphQL server and Raphtory UI using GraphServer. It then sends a graph to the server and performs a query. ```python tmp_work_dir = tempfile.mkdtemp() with GraphServer(tmp_work_dir, tracing=True).start(): client = RaphtoryClient("http://localhost:1736") client.send_graph(path="g", graph=new_graph) query = "{graph(path: \"g\") {nodes {list {name}}}}" client.query(query) ``` -------------------------------- ### Graph Data Transformation Examples Detailed Source: https://github.com/pometry/raphtory/blob/db_v4/docs/assets/mascot64.txt In-depth examples of various graph data transformation techniques. ```scala // Example: Node property mapping and filtering ``` -------------------------------- ### Build and Run Raphtory Server Source: https://github.com/pometry/raphtory/blob/db_v4/examples/docker/lotr/README.md Execute these commands in your shell to load the graph data and start the Raphtory Docker server. The first command prepares the graph data, and the second starts the server which automatically loads the prepared graph. ```shell python build_lotr.py docker compose up ``` -------------------------------- ### Chaining Graph Operations Configuration Example with Nested Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing chaining graph operations configuration with nested options. ```scala val config = ConfigFactory.parseString("raphtory.graph.chaining { maxDepth = 5 options { intermediateResults = \"save\" parallelism { level = 2 } } }") ``` -------------------------------- ### Graph Data Integration Patterns Examples Source: https://github.com/pometry/raphtory/blob/db_v4/docs/assets/mascot64.txt Practical examples of implementing common patterns for integrating graph data. ```scala // Example: Federated graph queries ``` -------------------------------- ### Graph Error Handling Configuration Example with Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph error handling configuration with specific options. ```scala val config = ConfigFactory.parseString("raphtory.graph.error { handling.strategy = \"log_and_continue\" options { logLevel = \"WARN\" } }") ``` -------------------------------- ### Monitoring and Metrics Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example related to monitoring performance or collecting metrics. ```scala val metrics = raphtory.getMetrics() ``` -------------------------------- ### Graph Data Query Language Examples Source: https://github.com/pometry/raphtory/blob/db_v4/docs/assets/mascot64.txt Practical examples of queries using different graph query languages. ```scala // Example: Gremlin query for finding neighbors ``` -------------------------------- ### Visualization Configuration Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of configuring a visualization in Raphtory. ```scala val config = ConfigFactory.parseString("raphtory.visualization.name = \"my_visualization\"") ``` -------------------------------- ### Install Python Libraries Source: https://github.com/pometry/raphtory/blob/db_v4/raphtory-benchmark/readme.md Install necessary Python libraries for running benchmarks outside of Docker. This includes libraries like networkx, scipy, matplotlib, raphtory, and kuzu. ```bash pip install networkx scipy matplotlib raphtory kuzu neo4j ``` -------------------------------- ### Resource Management Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example related to managing resources like memory or CPU. ```scala val config = ConfigFactory.parseString("raphtory.resources.memory = \"4g\"") ``` -------------------------------- ### Basic Raphtory Python Graph Example Source: https://github.com/pometry/raphtory/blob/db_v4/README.md Demonstrates creating a graph, adding nodes and edges with timestamps and properties, and collecting basic node metrics using a rolling window. This example requires pandas for result display. ```python from raphtory import Graph from raphtory import algorithms as algo import pandas as pd # Create a new graph graph = Graph() # Add some data to your graph graph.add_node(timestamp=1, id="Alice") graph.add_node(timestamp=1, id="Bob") graph.add_node(timestamp=1, id="Charlie") graph.add_edge(timestamp=2, src="Bob", dst="Charlie", properties={"weight": 5.0}) graph.add_edge(timestamp=3, src="Alice", dst="Bob", properties={"weight": 10.0}) graph.add_edge(timestamp=3, src="Bob", dst="Charlie", properties={"weight": -15.0}) # Check the number of unique nodes/edges in the graph and earliest/latest time seen. print(graph) results = [["earliest_time", "name", "out_degree", "in_degree"]] # Collect some simple node metrics Ran across the history of your graph with a rolling window for graph_view in graph.rolling(window=1): for v in graph_view.nodes: results.append( [graph_view.earliest_time, v.name, v.out_degree(), v.in_degree()] ) # Print the results print(pd.DataFrame(results[1:], columns=results[0])) ``` -------------------------------- ### Query Configuration Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of configuring a query in Raphtory. ```scala val config = ConfigFactory.parseString("raphtory.query.name = \"my_query\"") ``` -------------------------------- ### Graph Error Handling Configuration Example with Nested Options Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example showing graph error handling configuration with nested options. ```scala val config = ConfigFactory.parseString("raphtory.graph.error { handling.strategy = \"log_and_continue\" options { logLevel = \"WARN\" retry { count = 5 } } }") ``` -------------------------------- ### Load Graph from CSV and Start GraphQL Server Source: https://github.com/pometry/raphtory/blob/db_v4/README.md Loads graph data from a CSV file into a Raphtory Graph object, saves it, and then starts a GraphQL server to host the graph. Requires pandas and os modules. ```python from raphtory import Graph from raphtory.graphql import GraphServer import pandas as pd import os # URL for lord of the rings data from our main tutorial url = "https://raw.githubusercontent.com/Raphtory/Data/main/lotr-with-header.csv" df = pd.read_csv(url) # Load the lord of the rings graph from the dataframe graph = Graph() graph.load_edges(df,"time","src_id","dst_id") #Create a working_dir for your server and save your graph into it #You can save any number of graphs here or create them via the server ones its running os.makedirs("graphs/", exist_ok=True) graph.save_to_file("graphs/lotr_graph") # Launch the server and get a client to it. server = GraphServer(work_dir="graphs/").start() client = server.get_client() ``` -------------------------------- ### Output Path Configuration Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of configuring the output path for saving results. ```scala val config = ConfigFactory.parseString("raphtory.output.path = \"/path/to/output\"") ``` -------------------------------- ### Get Node Properties Source: https://github.com/pometry/raphtory/blob/db_v4/docs/assets/mascot64.txt Example of retrieving all properties associated with a specific node. ```scala val properties = graph.getNodeProperties("nodeId") ``` -------------------------------- ### Setting Configuration Values Programmatically Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of setting configuration values directly in the code. ```scala val updatedConfig = config.withValue("raphtory.output.path", ConfigValueFactory.fromAnyRef("/new/path")) ``` -------------------------------- ### Data Import Formats Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of specifying different formats for importing data. ```scala val csvData = raphtory.data("input.csv", format = "csv") ``` -------------------------------- ### Graph Algorithm Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Demonstrates using a specific graph algorithm, like PageRank. ```scala val pagerank = GraphAlgorithm.pagerank(graph) ``` -------------------------------- ### Install Python Package from Source Source: https://github.com/pometry/raphtory/blob/db_v4/CONTRIBUTING.md Installs the Raphtory Python package directly from its Git repository. Requires Rust toolchain and Python >= 3.11. ```bash pip install -e 'git+https://github.com/Raphtory/Raphtory.git#egg=raphtory&subdirectory=python' ``` -------------------------------- ### Get Two-Hop Neighbors and Zip with Node Names in Python Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/querying/6_chaining.md This example demonstrates chaining the 'neighbours' function twice to get two-hop neighbors. It then zips these neighbors with the node names and prints the results. Ensure your data is loaded and processed correctly before running. ```python import pandas as pd from raphtory import Graph from datetime import datetime edges_df = pd.read_csv( "../data/OBS_data.txt", sep="\t", header=0, usecols=[0, 1, 2, 3, 4], parse_dates=[0] ) edges_df["DateTime"] = pd.to_datetime(edges_df["DateTime"]) edges_df.dropna(axis=0, inplace=True) edges_df["Weight"] = edges_df["Category"].apply( lambda c: 1 if (c == "Affiliative") else (-1 if (c == "Agonistic") else 0) ) g = Graph() g.load_edges( data=edges_df, src="Actor", dst="Recipient", time="DateTime", layer_col="Behavior", properties=["Weight"], ) node_names = g.nodes.name two_hop_neighbours = g.nodes.neighbours.neighbours.name.collect() combined = zip(node_names, two_hop_neighbours) for name, two_hop_neighbour in combined: print(f"{name} has the following two hop neighbours {two_hop_neighbour}") ``` -------------------------------- ### Start Raphtory Server Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/getting-started/30_cli.md Starts the Raphtory GraphQL server on a specified port. The default port is 1736. Various configuration options are available via command-line flags. ```sh raphtory server --port 1736 ``` -------------------------------- ### Processing Step Configuration Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of configuring a processing step in Raphtory. ```scala val config = ConfigFactory.parseString("raphtory.process.name = \"my_process\"") ``` -------------------------------- ### Custom Process Implementation Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of implementing a custom processing step for Raphtory. ```scala class MyProcess extends Process { /* ... */ } ``` -------------------------------- ### Create Time-Bound Graph View with window() Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/views/2_time.md Use the window() function to filter an edge's history between a specified start and end datetime. This example demonstrates creating a view for a single day and printing interaction counts. ```Python import pandas as pd from raphtory import Graph from datetime import datetime import matplotlib.pyplot as plt edges_df = pd.read_csv( "../data/OBS_data.txt", sep="\t", header=0, usecols=[0, 1, 2, 3, 4], parse_dates=[0] ) edges_df["DateTime"] = pd.to_datetime(edges_df["DateTime"]) edges_df.dropna(axis=0, inplace=True) edges_df["Weight"] = edges_df["Category"].apply( lambda c: 1 if (c == "Affiliative") else (-1 if (c == "Agonistic") else 0) ) g = Graph() g.load_edges( data=edges_df, src="Actor", dst="Recipient", time="DateTime", layer_col="Behavior", properties=["Weight"], ) start_day = datetime.strptime("2019-06-13", "%Y-%m-%d") end_day = datetime.strptime("2019-06-14", "%Y-%m-%d") e = g.edge("LOME", "NEKKE") print( f"Across the full dataset {e.src.name} interacted with {e.dst.name} {len(e.history)} times" ) w = e.window(start_day, end_day) print( f"Between {w.start.dt} and {w.end.dt}, {w.src.name} interacted with {w.dst.name} {len(w.history)} times" ) print( f"Window start: {w.start.dt}, First update: {w.earliest_time.dt}, Last update: {w.latest_time.dt}, Window End: {w.end.dt}" ) ``` -------------------------------- ### Data Quality Monitoring Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of setting up continuous data quality monitoring. ```scala val monitorConfig = ConfigFactory.parseString("raphtory.quality.monitor.interval = \"1h\"") ``` -------------------------------- ### Assign Node Types and Start Raphtory Server for Visualization Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/algorithms/5_community_detection.md Assign human-readable labels to nodes based on their detected community and start a Raphtory GraphQL server. This prepares the graph for visualization in the Raphtory UI, where each community will have a distinct color. ```Python # Check value of cluster for each node and add to corresponding cluster list labels = {0:'Cobra Kai',1:'Miyagi-Do',2:'Polarslaget',3:'Redentores'} for node, cluster in clustering.items(): G.node(node).set_node_type(labels[cluster["community_id"]]) # Start a Raphtory server and send the karate graph server = graphql.GraphServer(".idea/my-test/graphs") client = server.start().get_client() client.send_graph("cluster-graph", G, overwrite=True) ``` ```Python assert len(G.get_all_node_types()) == 4 ``` -------------------------------- ### Custom Visualization Implementation Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of implementing a custom visualization for Raphtory. ```scala class MyVisualization extends Visualization { /* ... */ } ``` -------------------------------- ### NodeFieldFilterNew Example (GraphQL) Source: https://github.com/pometry/raphtory/blob/db_v4/docs/reference/graphql/graphql_API.md Example of how to use NodeFieldFilterNew with a Contains condition in GraphQL. ```APIDOC ### Request Example (GraphQL) ```graphql { Node: { field: NodeName, where: { Contains: "ali" } } } ``` ``` -------------------------------- ### Custom Data Source Implementation Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of implementing a custom data source for Raphtory. ```scala class MyDataSource extends DataSource { /* ... */ } ``` -------------------------------- ### Graph Traversal Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Demonstrates performing a traversal operation on a graph. ```scala val traversalResult = graph.traverse("start_node", "depth") ``` -------------------------------- ### Graph Analysis Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Illustrates performing an analysis on the graph, such as finding connected components. ```scala val analysisResult = graph.analyze("connected_components") ``` -------------------------------- ### Distributed Execution Setup Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Configuration or code snippet related to setting up distributed execution. ```scala val clusterConfig = ConfigFactory.parseString("raphtory.cluster.enabled = true") ``` -------------------------------- ### Data Export Formats Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of specifying different formats for exporting data. ```scala val csvExport = visualization.save("output.csv", format = "csv") val jsonExport = visualization.save("output.json", format = "json") ``` -------------------------------- ### Custom Query Implementation Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of implementing a custom query for Raphtory. ```scala class MyQuery extends Query { /* ... */ } ``` -------------------------------- ### Initialize and Configure Raphtory Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Demonstrates how to initialize and configure Raphtory. This is typically the first step before using any of its features. ```scala val raphtory = Raphtory(config) ``` -------------------------------- ### Combining Data from Different Sources Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of how to combine or join data from different sources. ```scala val combinedData = data1.join(data2, "join_key") ``` -------------------------------- ### Example .env File for Authentication Source: https://github.com/pometry/raphtory/blob/db_v4/raphtory-graphql/readme.md Configure authentication by creating a `.env` file in the project root with your Microsoft Azure AD credentials. Ensure this file is added to `.gitignore`. ```env CLIENT_ID=your_client_id CLIENT_SECRET=your_client_secret TENANT_ID=your_tenant_id AUTHORITY=https://login.microsoftonline.com/your_tenant_id ``` -------------------------------- ### Check Raphtory Version Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/getting-started/30_cli.md Use this command to display the installed version of the Raphtory CLI. ```sh raphtory --version ``` -------------------------------- ### Graph Data Transformation Examples Source: https://github.com/pometry/raphtory/blob/db_v4/docs/assets/mascot64.txt Illustrative examples of transforming graph data for specific analytical needs. ```scala // Example: Node property aggregation ``` -------------------------------- ### Configuration Loading from File Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Shows how to load Raphtory configuration from an external file. ```scala val config = ConfigFactory.load("application.conf") ``` -------------------------------- ### Error Handling Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Provides an example of how to handle potential errors during data processing, such as file not found exceptions. ```scala try { // Code that might throw an exception val df = spark.read.csv("non_existent_file.csv") } catch { case e: Exception => println(s"An error occurred: ${e.getMessage}") } ``` -------------------------------- ### Initialize and Configure Raphtory Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html This snippet shows how to initialize and configure Raphtory. Ensure all necessary dependencies are imported before use. ```scala import org.apache.spark.sql.SparkSession import org.apache.spark.sql.functions._ import org.apache.spark.sql.types._ val spark = SparkSession.builder().appName("Raphtory Example").getOrCreate() import spark.implicits._ ``` -------------------------------- ### Run Raphtory-GraphQL Server (With Auth) Source: https://github.com/pometry/raphtory/blob/db_v4/raphtory-graphql/readme.md Start the Raphtory-GraphQL server with Microsoft authentication enabled. This command uses the `--server` argument to invoke `run_with_auth`. ```bash cargo run -- --server ``` -------------------------------- ### Create and Analyze a Subgraph in Python Source: https://github.com/pometry/raphtory/blob/db_v4/docs/user-guide/views/4_subgraph.md Demonstrates loading graph data, creating a subgraph, and comparing node neighbors in the full graph versus the subgraph. It also shows how to apply a time window to the subgraph analysis. ```python import pandas as pd from raphtory import Graph from datetime import datetime edges_df = pd.read_csv( "../data/OBS_data.txt", sep="\t", header=0, usecols=[0, 1, 2, 3, 4], parse_dates=[0] ) edges_df["DateTime"] = pd.to_datetime(edges_df["DateTime"]) edges_df.dropna(axis=0, inplace=True) edges_df["Weight"] = edges_df["Category"].apply( lambda c: 1 if (c == "Affiliative") else (-1 if (c == "Agonistic") else 0) ) g = Graph() g.load_edges( data=edges_df, src="Actor", dst="Recipient", time="DateTime", layer_col="Behavior", properties=["Weight"], ) temp = g.count_nodes() print(f"There are {temp} monkeys in the whole graph") subgraph = g.subgraph(["FELIPE", "LIPS", "NEKKE", "LOME", "BOBO"]) print(f"There are {subgraph.count_nodes()} monkeys in the subgraph") neighbours = g.node("FELIPE").neighbours.name.collect() print(f"FELIPE has the following neighbours in the full graph: {neighbours}") neighbours = subgraph.node("FELIPE").neighbours.name.collect() print(f"FELIPE has the following neighbours in the subgraph: {neighbours}") start_day = datetime.strptime("2019-06-17", "%Y-%m-%d") end_day = datetime.strptime("2019-06-18", "%Y-%m-%d") neighbours = ( subgraph.node("FELIPE").window(start_day, end_day).neighbours.name.collect() ) print( f"FELIPE has the following neighbours in the subgraph between {start_day} and {end_day}: {neighbours}" ) ``` ```python assert str(f"FELIPE has the following neighbours in the subgraph between {start_day} and {end_day}: {neighbours}") == "FELIPE has the following neighbours in the subgraph between 2019-06-17 00:00:00 and 2019-06-18 00:00:00: ['NEKKE']" ``` -------------------------------- ### Run Raphtory-GraphQL Server (No Auth) Source: https://github.com/pometry/raphtory/blob/db_v4/raphtory-graphql/readme.md Start the Raphtory-GraphQL server in its default configuration without authentication. This command utilizes the `from_directory.run` function. ```bash cargo run ``` -------------------------------- ### Initialize a Graph with Nodes and Edges Source: https://github.com/pometry/raphtory/blob/db_v4/docs/assets/mascot64.txt Demonstrates how to initialize a graph in Raphtory, adding nodes and edges. Ensure you have the necessary imports. ```scala import org.apache.spark.sql.SparkSession import org.apache.spark.sql.functions._ import org.graph4j.Graph object GraphInitialization { def main(args: Array[String]): Unit = { val spark = SparkSession.builder().appName("GraphInitialization").master("local[*]").getOrCreate() // Create a new graph val graph = new Graph[String, String]() // Add nodes graph.addNode("node1", "Node 1") graph.addNode("node2", "Node 2") graph.addNode("node3", "Node 3") // Add edges graph.addEdge("edge1", "node1", "node2", "Edge 1-2") graph.addEdge("edge2", "node2", "node3", "Edge 2-3") graph.addEdge("edge3", "node1", "node3", "Edge 1-3") println("Graph initialized successfully.") println(s"Number of nodes: ${graph.nodes.size()}") println(s"Number of edges: ${graph.edges.size()}") spark.stop() } } ``` -------------------------------- ### GraphQL NodeFieldFilterNew Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/reference/graphql/graphql_API.md Example of filtering nodes by name using NodeFieldFilterNew in GraphQL. It specifies the 'NodeName' field and a 'Contains' condition. ```graphql { Node: { field: NodeName, where: { Contains: "ali" } } } ``` -------------------------------- ### Accessing Configuration Values Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Demonstrates how to access specific configuration values. ```scala val dataSourceName = config.getString("raphtory.data.source.name") ``` -------------------------------- ### Install Raphtory for Python and Rust Source: https://context7.com/pometry/raphtory/llms.txt Install Raphtory using pip for Python or cargo for Rust projects. Ensure you meet the minimum version requirements. ```bash # Python (3.8+) pip install raphtory ``` ```bash # Rust (1.77+) cargo add raphtory ``` -------------------------------- ### Graph Traversal Example (BFS) Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Illustrates a basic graph traversal algorithm like Breadth-First Search (BFS). This is useful for finding shortest paths. ```scala // BFS implementation would typically involve Spark GraphX or a similar library println("BFS traversal example not provided.") ``` -------------------------------- ### Applying Multiple Processes Sequentially Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Demonstrates applying several processing steps one after another. ```scala val processedData = data.process("process1").process("process2") ``` -------------------------------- ### GraphQL Time Window Filter Example Source: https://github.com/pometry/raphtory/blob/db_v4/docs/reference/graphql/graphql_API.md Example of how to use the Window filter in GraphQL to restrict graph data to a specific time range and apply a nested filter. ```graphql { Window: { start: 0, end: 10, expr: { Layers: { names: ["A"] } } } } ``` -------------------------------- ### Access Node Edge Start Time Source: https://github.com/pometry/raphtory/blob/db_v4/python/tests/test_base_install/base_notebook.ipynb Accesses the start time of edges associated with nodes. This is a direct property access and might be used for quick checks on edge temporal properties. ```python g.nodes.edges.start ``` -------------------------------- ### View Raphtory Documentation Source: https://github.com/pometry/raphtory/blob/db_v4/CONTRIBUTING.md Opens the locally built Raphtory documentation in a web browser. ```bash open build/html/index.html ``` -------------------------------- ### Configuration for Data Storage Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Shows how to configure data storage options, such as specifying the output directory and format. ```scala val outputPath = "s3://my-bucket/raphtory/output" val outputFormat = "parquet" ``` -------------------------------- ### Data Sampling Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of sampling a subset of data. ```scala val sampleData = data.sample(0.1) ``` -------------------------------- ### Data Masking Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of data masking techniques. ```scala val maskedData = data.mask("credit_card_number", "****-****-****-") ``` -------------------------------- ### Build Raphtory Documentation Source: https://github.com/pometry/raphtory/blob/db_v4/CONTRIBUTING.md Builds the HTML version of the Raphtory documentation. ```bash cd docs && make html ``` -------------------------------- ### Using Different Data Sources Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Illustrates loading data from multiple, distinct data sources. ```scala val data1 = raphtory.data("source1") val data2 = raphtory.data("source2") ``` -------------------------------- ### Clone Raphtory Repository Source: https://github.com/pometry/raphtory/blob/db_v4/raphtory-graphql/readme.md Clone the Raphtory project repository and navigate to the raphtory-graphql directory to begin setup. ```bash git clone https://github.com/Pometry/Raphtory.git cd Raphtory/raphtory-graphql ``` -------------------------------- ### Data Enrichment Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of enriching data with external information. ```scala val enrichedData = data.enrich("external_service") ``` -------------------------------- ### Schema Registry Integration Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of integrating with a schema registry. ```scala val schemaFromRegistry = SchemaRegistry.get("my_schema") ``` -------------------------------- ### Complete Temporal Graph Analysis Workflow Source: https://context7.com/pometry/raphtory/llms.txt Demonstrates graph creation, temporal analysis with rolling windows, property tracking, and algorithm execution. Requires Raphtory, pandas, and algorithms. ```python from raphtory import Graph from raphtory import algorithms as algo import pandas as pd # Create graph and add temporal data graph = Graph() # Add nodes with evolving properties graph.add_node(timestamp=1, id="Alice", properties={"balance": 100}) graph.add_node(timestamp=2, id="Alice", properties={"balance": 150}) graph.add_node(timestamp=3, id="Alice", properties={"balance": 200}) graph.add_node(timestamp=1, id="Bob", properties={"balance": 50}) graph.add_node(timestamp=2, id="Bob", properties={"balance": 75}) graph.add_node(timestamp=1, id="Charlie", properties={"balance": 80}) # Add edges representing transactions graph.add_edge(timestamp=2, src="Bob", dst="Charlie", properties={"amount": 50}) graph.add_edge(timestamp=3, src="Alice", dst="Bob", properties={"amount": 100}) graph.add_edge(timestamp=3, src="Bob", dst="Charlie", properties={"amount": -15}) print(graph) # Output: Graph(number_of_nodes=3, number_of_edges=2, ...) # Analyze with rolling windows print("\nRolling window analysis:") for view in graph.rolling(window=1): print(f" Time {view.end.t}: {view.count_edges()} edges, {view.count_nodes()} active nodes") # Track property changes bob_charlie = graph.edge("Bob", "Charlie") amount_history = bob_charlie.properties.temporal.get("amount").items() print(f"\nTransaction history (Bob->Charlie): {amount_history}") # Output: [(2, 50), (3, -15)] # Compare values at different times change = bob_charlie.at(2)["amount"] - bob_charlie.at(3)["amount"] print(f"Amount change: {change}") # Output: 65 # Run PageRank algorithm top_node = algo.pagerank(graph).top_k({"pagerank_score": "desc"}, 1).max_item() print(f"\nMost important node: {top_node[0].name} (score: {top_node[1]['pagerank_score']:.4f})") # Export results to DataFrame df = graph.nodes.to_df(include_property_history=True, convert_datetime=True) print(f"\nExported {len(df)} nodes to DataFrame") ``` -------------------------------- ### Metadata Management Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of managing metadata associated with data. ```scala val metadata = data.getMetadata() ``` -------------------------------- ### Schema Definition Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of defining a schema for data processing. ```scala val schema = Map("col1" -> "string", "col2" -> "integer") ``` -------------------------------- ### Real-time Data Ingestion Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of ingesting data in real-time. ```scala val realTimeData = raphtory.ingest("kafka_topic") ``` -------------------------------- ### Streaming Data Visualization Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of visualizing data from a stream in real-time. ```scala eventStream.visualize("real_time_dashboard") ``` -------------------------------- ### Feature Engineering Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example of creating new features from existing data. ```scala val engineeredFeatures = data.createFeature("feature_name", "formula") ``` -------------------------------- ### Caching Mechanism Source: https://github.com/pometry/raphtory/blob/db_v4/docs/overrides/404.html Example related to enabling or configuring a caching mechanism. ```scala val config = ConfigFactory.parseString("raphtory.caching.enabled = true") ``` -------------------------------- ### Build Rust Core from Source Source: https://github.com/pometry/raphtory/blob/db_v4/CONTRIBUTING.md Builds the Raphtory Rust core using Cargo. Requires the Rust toolchain. ```bash make rust-build ``` ```bash cargo build ```