pygraphs.adjacency_list_to_edges_list#
- adjacency_list_to_edges_list(adjacency, *, skip_validation=False)[source]#
Convert a graph represented as an adjacency list (
AdjacencyList) to a graph represented as an edge list (Edges).AdjacencyList:
List[List[Integral]]]: A list of lists, where the outer list has a length equal to the number of vertices in the graph, and each inner list contains the neighbors (i.e.,[v1, v2, ...]) of the corresponding vertex (from outer vertex to inner vertex). For a weighted graph, the formList[List[Tuple[Integral, Real]]]is used where the inner lists contain tuples of the form \((v, w)\), where \(v\) is a neighbor vertex and \(w\) is the weight of the edge connecting the vertex to its neighbor. To store more than weight, the formList[List[Tuple[Integral, Dict[str, Any]]]]is used.
Edges:
List[Tuple[Integral, Integral]]: A list of tuples, where each tuple represents an edge \((u, v)\) in the graph (from vertex \(u\) to vertex \(v\)). For a undirected graph consider converting inpygraphs.Graphclass and use theto_undirectedmethod to duplicate \((u, v)\) into \((u, v)\) and \((v, u)\). For a weighted graph, the formList[Tuple[Integral, Integral, Real]]containing \((u, v, w)\) is used, where \(u\) and \(v\) are the vertices connected by the edge and \(w\) is the weight of the edge. To store more than weight, the formList[Tuple[Integral, Integral, Dict[str, Any]]]is used.
- Parameters:
adjacency (AdjacencyList) – The adjacency list to convert into an edge list.
- Returns:
edge_list – The graph represented as an edge list.
- Return type:
Edges