netrd/utilities/graph.py
def create_graph(A, create_using=None, remove_self_loops=True):
    """
    Function for flexibly creating a networkx graph from a numpy array.

    Params
    ------
    A (np.ndarray): A numpy array.
    create_using (nx.Graph or None): Create the graph using a specific networkx graph.
    Can be used for forcing an asymmetric matrix to create an undirected graph, for example.
    remove_self_loops (bool): If True, remove the diagonal of the matrix before creating the
    graph object.

    Returns
    -------
    G: A graph, typically a nx.Graph or nx.DiGraph.

    """
    if remove_self_loops:
        np.fill_diagonal(A, 0)

    if create_using is None:
        if np.allclose(A, A.T):
            G = nx.from_numpy_array(G, create_using=nx.Graph)
        else:
            G = nx.from_numpy_array(G, create_using=nx.DiGraph)
    else:
        G = nx.from_numpy_array(A, create_using=create_using)

    return G

    Function for flexibly creating a networkx graph from a numpy array.

    Params
    ------
    A (np.ndarray): A numpy array.
    create_using (nx.Graph or None): Create the graph using a specific networkx graph.
    Can be used for forcing an asymmetric matrix to create an undirected graph, for example.
    remove_self_loops (bool): If True, remove the diagonal of the matrix before creating the
    graph object.

    Returns
    -------
    G: A graph, typically a nx.Graph or nx.DiGraph.

    
Function for flexibly creating a networkx graph from a numpy array.
Params

A (np.ndarray): A numpy array.
create_using (nx.Graph or None): Create the graph using a specific networkx graph.
Can be used for forcing an asymmetric matrix to create an undirected graph, for example.
remove_self_loops (bool): If True, remove the diagonal of the matrix before creating the
graph object.

Returns


Function for flexibly creating a networkx graph from a numpy array . Params A ( np . ndarray ) : A numpy array . create_using ( nx . Graph or None ) : Create the graph using a specific networkx graph . Can be used for forcing an asymmetric matrix to create an undirected graph for example . remove_self_loops ( bool ) : If True remove the diagonal of the matrix before creating the graph object . Returns
def create_graph(A, create_using=None, remove_self_loops=True):
    if remove_self_loops:
        np.fill_diagonal(A, 0)
    if create_using is None:
        if np.allclose(A, A.T):
            G = nx.from_numpy_array(G, create_using=nx.Graph)
        else:
            G = nx.from_numpy_array(G, create_using=nx.DiGraph)
    else:
        G = nx.from_numpy_array(A, create_using=create_using)
    return G
def create_graph ( A , create_using = None , remove_self_loops = True ) : if remove_self_loops : np . fill_diagonal ( A , 0 ) if create_using is None : if np . allclose ( A , A . T ) : G = nx . from_numpy_array ( G , create_using = nx . Graph ) else : G = nx . from_numpy_array ( G , create_using = nx . DiGraph ) else : G = nx . from_numpy_array ( A , create_using = create_using ) return G
Function for flexibly creating a networkx graph from a numpy array.
Function for flexibly creating a networkx graph from a numpy array .
"""
    Function for flexibly creating a networkx graph from a numpy array.

    Params
    ------
    A (np.ndarray): A numpy array.
    create_using (nx.Graph or None): Create the graph using a specific networkx graph.
    Can be used for forcing an asymmetric matrix to create an undirected graph, for example.
    remove_self_loops (bool): If True, remove the diagonal of the matrix before creating the
    graph object.

    Returns
    -------
    G: A graph, typically a nx.Graph or nx.DiGraph.

    """
A
create_using
remove_self_loops