flpq_data.graphs.readwrite.graph#

The edge stream of an in-memory graph.

Functions

iter_edges_from_graph(graph)

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’s label attribute — the one every graph_from_* reader sets and every graph_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)]