Exemplo n.º 1
0
def edge_lines_to_graph(edge_lines):
    probe_graph = dict([(i_site,set([])) for i_site in xrange(N_SITES)])
    site_names = [site.name for site in PROBE_SITES]
    for line in edge_lines:
        src,targ = line.split()
        add_edge(probe_graph,site_names.index(src),site_names.index(targ))
    return probe_graph
Exemplo n.º 2
0
def edge_lines_to_graph(edge_lines):
    probe_graph = dict([(i_site, set([])) for i_site in xrange(N_SITES)])
    site_names = [site.name for site in PROBE_SITES]
    for line in edge_lines:
        src, targ = line.split()
        add_edge(probe_graph, site_names.index(src), site_names.index(targ))
    return probe_graph
Exemplo n.º 3
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.º 4
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