graphi.graph_io.graphml.reader module¶
-
graphi.graph_io.graphml.reader.graph_reader(source, node_type=<function id_node>, value_type=<function true_namespace_value>)¶ Read a graph from GraphML
sourceParameters: - source – a string, file path or file object containing GraphML data
- node_type (Callable[[GraphMLNode], Any]) – type converter for nodes
- value_type (Callable[[GraphMLEdge], Any]) – type converter for edges
Returns: Iterable[AdjacencyGraph]
Since a GraphML file may contain multiple graphs, an iterable over all contained graphs is returned.
# read a single graph graph, = graph_reader(source_path) # read several graphs graphs = list(graph_reader(source_path)) # stream through graphs for graph in graph_reader(source_path): ...
The
node_typeandvalue_typeare used to convert the GraphML-specificGraphMLNodeandGraphMLEdgeto generic nodes and edge values. As edges are defined by nodes, there is no separate converter.
-
graphi.graph_io.graphml.reader.id_node(node)¶ Create nodes from their
idfield