data_structures/graphs/utils.py
def adjacency_list_to_nx_graph(g):
    """
    Convert a graph represented as an adjacency list to a networkx graph.
    Only for unweighted graphs.

    :type g: list(list)
    :return: networkx graph
    """
    n = len(g)
    d = {}

    for node in range(n):
        neighbours = {}
        for neighbour in g[node]:
            neighbours[neighbour] = 1
        d[node] = neighbours

    return nx.Graph(d)

    Convert a graph represented as an adjacency list to a networkx graph.
    Only for unweighted graphs.

    :type g: list(list)
    :return: networkx graph
    
Convert a graph represented as an adjacency list to a networkx graph.
Only for unweighted graphs.
Convert a graph represented as an adjacency list to a networkx graph . Only for unweighted graphs .
def adjacency_list_to_nx_graph(g):
    n = len(g)
    d = {}
    for node in range(n):
        neighbours = {}
        for neighbour in g[node]:
            neighbours[neighbour] = 1
        d[node] = neighbours
    return nx.Graph(d)
def adjacency_list_to_nx_graph ( g ) : n = len ( g ) d = { } for node in range ( n ) : neighbours = { } for neighbour in g [ node ] : neighbours [ neighbour ] = 1 d [ node ] = neighbours return nx . Graph ( d )
Convert a graph represented as an adjacency list to a networkx graph.
Convert a graph represented as an adjacency list to a networkx graph .
"""
    Convert a graph represented as an adjacency list to a networkx graph.
    Only for unweighted graphs.

    :type g: list(list)
    :return: networkx graph
    """
None
g