| [ Web Proxy ] |
| Viewing: https://memgraph.com/docs/mage/query-modules/python/graph-analyzer | [Back] [Original] |
The graph_analyzer provides a deep analytics of the current state of the
graph. Various different graph properties are extracted using NetworX.
The list of analytics that the module uses:
| Trait | Value |
|---|---|
| Module type | module |
| Implementation | Python |
| Graph direction | undirected |
| Edge weights | unweighted |
| Parallelism | sequential |
You can execute this algorithm on graph projections, subgraphs or portions of the graph.
analyze()The procedure analyzes the graph and returns information.
subgraph: Graph (OPTIONAL) A specific subgraph, which is an object of type Graph returned by the project() function, on which the algorithm is run.
If subgraph is not specified, the algorithm is computed on the entire graph by default.
analyses: List[string] (default=NULL) List of analytics names to be fetched. If provided with NULL, the whole set of analytics will be included.
name: string The name of the analytics.value: string Analytics value, stored as a string.Use the following query to analyze the graph:
CALL graph_analyzer.analyze()
YIELD name, value
RETURN name, value;analyze_subgraph()The procedure analyzes a subgraph and returns information.
subgraph: Graph (OPTIONAL) A specific subgraph, which is an object of type Graph returned by the project() function, on which the algorithm is run.
If subgraph is not specified, the algorithm is computed on the entire graph by default.
vertices: List[Vertex] Subset of vertices within a graph.
edges: List[Edge] Subset of relationships in a graph for which analytics will take place.
analyses: List[string] (default=NULL) List of analytics names to be fetched. If provided with NULL, thewhole set of analytics will be included.
name: string The name of the analytics.value: string Analytics value, stored as a string.Use the following query to analyze a subgraph:
MATCH (n)-[e]-(m)
WITH COLLECT(n) AS nodes_subset, COLLECT(e) AS edges_subset
CALL graph_analyzer.analyze(nodes_subset, edges_subset) YIELD name, value
RETURN name, value;help()Shows the manual page for graph_analyzer.
None.
name: string The name of the procedure.value: string Explanation of the procedure.Use the following query to analyze the graph:
CALL graph_analyzer.help()
YIELD name, value
RETURN name, value;The database contains the following data:
Created with the following Cypher queries:
MERGE (a:Node {id: 0}) MERGE (b:Node {id: 1}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 1}) MERGE (b:Node {id: 2}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 1}) MERGE (b:Node {id: 3}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 2}) MERGE (b:Node {id: 3}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 2}) MERGE (b:Node {id: 4}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 3}) MERGE (b:Node {id: 4}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 1}) MERGE (b:Node {id: 5}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 0}) MERGE (b:Node {id: 6}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 5}) MERGE (b:Node {id: 6}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 5}) MERGE (b:Node {id: 7}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 5}) MERGE (b:Node {id: 8}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 7}) MERGE (b:Node {id: 8}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 8}) MERGE (b:Node {id: 9}) CREATE (a)-[:RELATION]->(b);
MERGE (a:Node {id: 10}) MERGE (b:Node {id: 11}) CREATE (a)-[:RELATION]->(b);Get the values using the following query:
CALL graph_analyzer.analyze([
"nodes", "edges", "bridges", "articulation_points",
"avg_degree", "is_dag", "is_tree", "strongly_components"
])
YIELD name, value
RETURN name, value;Results:
+-------------------------------------------+-------------------------------------------+
| name | value |
+-------------------------------------------+-------------------------------------------+
| "Number of nodes" | "12" |
| "Number of edges" | "14" |
| "Number of bridges" | "2" |
| "Number of articulation points" | "3" |
| "Average degree" | "1.1666666666666667" |
| "Is DAG" | "True" |
| "Is tree" | "False" |
| "Number of strongly connected components" | "12" |
+-------------------------------------------+-------------------------------------------+| Web Proxy Viewer | New URL | Original Page |