flpq_data.graphs.readwrite.graph#
The edge stream of an in-memory graph.
Functions
|
Yields the edges of an in-memory graph as a stream. |
- iter_edges_from_graph(graph: MultiDiGraph) Iterator[Tuple[Any, str, Any]][source]#
Yields the edges of an in-memory graph as a stream.
Each edge key yields
(u, label, v)with the label taken from the edge’slabelattribute — the one everygraph_from_*reader sets and everygraph_to_*writer consumes.- Parameters:
- graphMultiDiGraph
The graph whose edges will be yielded.
- Returns:
- edgesIterator[Tuple[Any, str, Any]]
The
(u, label, v)edge tuples in graph order.
Examples
>>> import networkx as nx >>> g = nx.MultiDiGraph() >>> _ = g.add_edges_from([(0, 1, {"label": "a"}), (1, 2, {"label": "b_5"})]) >>> list(iter_edges_from_graph(g)) [(0, 'a', 1), (1, 'b_5', 2)]