コード例 #1
0
ファイル: digraph.py プロジェクト: prajita/staticgraph
def make(n_nodes, n_edges, edges):
    """
    Make a DiGraph.

    n_nodes - # nodes in the graph.
              The graph contains all nodes form 0 to (n_nodes - 1)
    n_edges - an over estimate of the number of edges
    edges   - an iterable producing the edges of the graph
    """

    n_nodes = int(n_nodes)
    n_edges = int(n_edges)

    # Create the edgelist
    es = edgelist.make(n_nodes, n_edges, edges)

    # Compact the edgelist
    s_indptr, s_indices = edgelist.compact(n_nodes, es)

    # Swap and sort for getting compact predecessors
    edgelist.swap(es)
    es.sort()

    # Compact the edgelist
    p_indptr, p_indices = edgelist.compact(n_nodes, es)

    # Create the graph
    G = DiGraph(n_nodes, len(es), p_indptr, p_indices, s_indptr, s_indices)
    return G
コード例 #2
0
ファイル: digraph.py プロジェクト: prajita/staticgraph
def make(n_nodes, n_edges, edges):
    """
    Make a DiGraph.

    n_nodes - # nodes in the graph.
              The graph contains all nodes form 0 to (n_nodes - 1)
    n_edges - an over estimate of the number of edges
    edges   - an iterable producing the edges of the graph
    """

    n_nodes = int(n_nodes)
    n_edges = int(n_edges)

    # Create the edgelist
    es = edgelist.make(n_nodes, n_edges, edges)

    # Compact the edgelist
    s_indptr, s_indices = edgelist.compact(n_nodes, es)

    # Swap and sort for getting compact predecessors
    edgelist.swap(es)
    es.sort()

    # Compact the edgelist
    p_indptr, p_indices = edgelist.compact(n_nodes, es)

    # Create the graph
    G = DiGraph(n_nodes, len(es), p_indptr, p_indices, s_indptr, s_indices)
    return G
コード例 #3
0
def make(n_nodes, n_edges, edges):
    """
    Make a Graph.

    n_nodes - # nodes in the graph.
              The graph contains all nodes form 0 to (n_nodes - 1)
    n_edges - an over estimate of the number of edges
    edges   - an iterable producing the edges of the graph
    """

    n_nodes = int(n_nodes)
    n_edges = int(n_edges)

    # Create the edgelist
    es = edgelist.make(n_nodes, n_edges, edges)

    # Compact the edgelist
    n_indptr, n_indices = edgelist.compact(n_nodes, es)

    # Create the graph
    G = Graph(n_nodes, len(es), n_indptr, n_indices)
    return G
コード例 #4
0
ファイル: graph.py プロジェクト: prajita/staticgraph
def make(n_nodes, n_edges, edges):
    """
    Make a Graph.

    n_nodes - # nodes in the graph.
              The graph contains all nodes form 0 to (n_nodes - 1)
    n_edges - an over estimate of the number of edges
    edges   - an iterable producing the edges of the graph
    """

    n_nodes = int(n_nodes)
    n_edges = int(n_edges)

    # Create the edgelist
    es = edgelist.make(n_nodes, n_edges, edges)

    # Compact the edgelist
    n_indptr, n_indices = edgelist.compact(n_nodes, es)

    # Create the graph
    G = Graph(n_nodes, len(es), n_indptr, n_indices)
    return G