Exemplo n.º 1
0
def make_graph():
    if PROBE_DIM == 0:
        return complete_graph(N_SITES)
    elif PROBE_DIM == 1:
        x = [site.x for site in PROBE_SITES]
        return path_graph(x)
    elif PROBE_DIM == 2:
        xy = [(site.x,site.y) for site in PROBE_SITES]
        return triangle_graph(xy)
Exemplo n.º 2
0
def make_graph():
    if PROBE_DIM == 0:
        return complete_graph(N_SITES)
    elif PROBE_DIM == 1:
        x = [site.x for site in PROBE_SITES]
        return path_graph(x)
    elif PROBE_DIM == 2:
        xy = [(site.x, site.y) for site in PROBE_SITES]
        return triangle_graph(xy)
Exemplo n.º 3
0
def triangle_graph(Locs):
    """
    Returns a graph giving the Delaunay triangulation of a set of two-dimensional points    

    Parameters
    -------
    Locs : ndarray, or anything that gets cast into ndarray upon np.array(Locs)
        Locs.shape = (n,2), where n is the number of points

    Returns
    ------
    out : networkx Graph
    """
    Locs = np.array(Locs)
    if len(Locs)==1:
        return complete_graph(1)
    else:
        Triangulation = sd.Triangulation(Locs[:,0],Locs[:,1])
        return Triangulation.node_graph()
Exemplo n.º 4
0
def triangle_graph(Locs):
    """
    Returns a graph giving the Delaunay triangulation of a set of two-dimensional points    

    Parameters
    -------
    Locs : ndarray, or anything that gets cast into ndarray upon np.array(Locs)
        Locs.shape = (n,2), where n is the number of points

    Returns
    ------
    out : networkx Graph
    """
    Locs = np.array(Locs)
    if len(Locs) == 1:
        return complete_graph(1)
    else:
        Triangulation = sd.Triangulation(Locs[:, 0], Locs[:, 1])
        return Triangulation.node_graph()
Exemplo n.º 5
0
def path_graph(Locs):
    """
    Returns a line graph for a set of one-dimensional locations.    

    Parameters
    -------
    Locs : ndarray, or anything that gets cast into ndarray upon np.array(Locs)

    Returns
    ------
    out : graph, i.e. dictionary key -> set(keys)
    """
    Locs = np.array(Locs).flatten()
    if len(Locs)==1:
        return complete_graph(1)    
    else:
        G = {}
        SortInds = np.argsort(Locs)
        for src,targ in zip(SortInds[1:],SortInds[:-1]):
            add_edge(G,src,targ)
        return G
Exemplo n.º 6
0
def path_graph(Locs):
    """
    Returns a line graph for a set of one-dimensional locations.    

    Parameters
    -------
    Locs : ndarray, or anything that gets cast into ndarray upon np.array(Locs)

    Returns
    ------
    out : graph, i.e. dictionary key -> set(keys)
    """
    Locs = np.array(Locs).flatten()
    if len(Locs) == 1:
        return complete_graph(1)
    else:
        G = {}
        SortInds = np.argsort(Locs)
        for src, targ in zip(SortInds[1:], SortInds[:-1]):
            add_edge(G, src, targ)
        return G