Exemplo n.º 1
0
def q4(cube, pyramid, show=False):
    matriz_projecao = [[1, 0, 0], [0, 1, 0], [0, 0, 0]]

    fig = plt.figure()
    ax = fig.add_subplot(111)

    cube_faces = get_rectangle_faces(np.dot(cube, matriz_projecao))
    arestas = get_edges(cube_faces)
    arestas = iterable_to_list(arestas)

    for aresta in arestas:
        aresta = np.array(aresta)
        ax.plot(aresta[:, 0], aresta[:, 1], color='blue')

    cube_faces = get_triangle_faces(np.dot(pyramid, matriz_projecao))
    arestas = get_edges(cube_faces)
    arestas = iterable_to_list(arestas)

    for aresta in arestas:
        aresta = np.array(aresta)
        ax.plot(aresta[:, 0], aresta[:, 1], color='red')

    plt.gca().set_aspect('equal')
    ax.set_xlim([-6, 6])
    ax.set_ylim([-6, 6])
    if show:
        plt.show()
    else:
        plt.savefig(ROOT_DIR / 'gif_images' / (str(datetime.now()) + ".png"))
Exemplo n.º 2
0
def create_graph_weights(nodeweights, fname):
    positions = pk.load(open("county_locations.dict"))
    positions = sorted(positions.items(), key=lambda (k, v) : k)
    positions = map(lambda (k, v) : (v[1], v[0]), positions)

    names = utils.get_name_map("../mississippi_county.list")
    edges = utils.get_edges("../mississippi_graph_NS.csv", names)

    g = Graph()
    g.set_directed(True)
    vertices = g.add_vertex(len(names))
    cap = g.new_edge_property("double")
    pos = g.new_vertex_property("vector<double>")
    colors = g.new_vertex_property("vector<double>")

    for i in range(len(nodeweights)):
        colors[i] = color_from_weight(nodeweights[i])

    for p in range(len(positions)):
        (x, y) = positions[p]
        pos[p] = [x, -y]

    for e in edges:
        edge = g.add_edge(e[0], e[1])
        cap[edge] = e[2]

    graph_draw(g, pos=pos, edge_pen_width=prop_to_size(cap, mi=1, ma=10, power=1),
            vertex_fill_color=colors,
            vertex_text=g.vertex_index,
            vertex_font_size=15, output=fname,
            fit_view=True, output_size=(800, 1200))
Exemplo n.º 3
0
def route_datasets(request):
    routes = get_routes(SOURCE, DESTINATION)
    #print routes

    try:
        route = routes[int(request.GET.get("route_index"))]
    except:
        route = routes[0]
    edges = get_edges(route)

    #route = [1, 2, 5, 4, 7, 6, 3, 9, 8, 10]
    #edges = get_edges_by_index(route)

    #edges = Edge.objects.all()[:5]
    edges = serialize('geojson', edges)
    return HttpResponse(edges, content_type='json')
Exemplo n.º 4
0
def build_rules():
    """ Actin network rules.
        Changes from initial model:
            * direct activation link RhoA -> Rac1
            * ROCK inhibition delay: RhoA -> ROCK -> ROCK_ -| Rac1
            * weaker RhoA inhibition rule: not Rac1 or not PAK
        Changes from v1:
            * strong inhibitors for Arp2_3 (reworked voting rule)
            * reworked rule for Cortactin
        Changes from v2:
            * deleted PKD activates PAK
            * added link PKD activates LIMK
            * Option A: deleted PAK -> Cortactin link
            * deleted IRSp53 -> WAVE link
            * deleted Rac1 -> IRSp53 link
        Changes from v3:
            * separate IRSp53 variants Cdc42 and Rac1 activations
    """

    UPSTREAM = "UPSTREAM"

    G = nx.DiGraph()
    rules = ""

    rules += "1: UPSTREAM* = not UPSTREAM \n"

    G.add_weighted_edges_from(
        get_edges(WASP, [Rac1, Cdc42, PIP2, Cortactin, IRSp53_Cdc42],
                  [Thymosin]))
    rules += "1: WASP* = not Thymosin and (Rac1 or Cdc42 or PIP2 or Cortactin or IRSp53_Cdc42) \n"

    G.add_weighted_edges_from(get_edges(WAVE, [Rac1, IRSp53_Rac1], []))
    rules += "1: WAVE* = Rac1 or IRSp53_Rac1 \n"

    G.add_weighted_edges_from(
        get_edges(Arp2_3, [PAK, WASP, WAVE, Cortactin],
                  [Profilin, Thymosin, Coronin]))
    rules += "1: Arp2_3* = PAK and (" + voting_rule(
        [WASP, WAVE, Cortactin], [Profilin, Thymosin, Coronin]) + ")\n"

    G.add_weighted_edges_from(get_edges(Rac1, [UPSTREAM], []))
    rules += "1: Rac1* = UPSTREAM \n"

    G.add_weighted_edges_from(get_edges(RhoA, [], [UPSTREAM]))
    rules += "1: RhoA* = not UPSTREAM \n"

    G.add_weighted_edges_from(get_edges(Thymosin, [], [WASP, Cofilin]))
    rules += "1: Thymosin* = (not WASP and not Cofilin) \n"

    G.add_weighted_edges_from(get_edges(Cortactin, [Rac1], [Coronin, PKD]))
    rules += "1: Cortactin* = " + voting_rule([Rac1], [Coronin, PKD]) + " \n"

    G.add_weighted_edges_from(get_edges(IRSp53_Cdc42, [Cdc42], []))
    rules += "1: IRSp53_Cdc42* = Cdc42 \n"

    G.add_weighted_edges_from(get_edges(IRSp53_Rac1, [Rac1], []))
    rules += "1: IRSp53_Rac1* = Rac1 \n"

    G.add_weighted_edges_from(get_edges(PAK, [Rac1, Cdc42], []))
    rules += "1: PAK* = Rac1 or Cdc42 \n"

    G.add_weighted_edges_from(get_edges(Dia1, [RhoA], [CP]))
    rules += "1: Dia1* = RhoA and not CP \n"

    G.add_weighted_edges_from(get_edges(Dia2, [Rac1, RhoA], []))
    rules += "1: Dia2* = Rac1 or RhoA \n"

    G.add_weighted_edges_from(
        get_edges(Ena_Vasp, [IRSp53_Cdc42, WASP, PKD], []))
    rules += "1: Ena_Vasp* = IRSp53_Cdc42 or WASP or PKD \n"

    G.add_weighted_edges_from(
        get_edges(Profilin, [WASP, Dia1, WAVE], [Thymosin, PIP2]))
    rules += "1: Profilin* = " + voting_rule(["WASP", "Dia1", "WAVE"],
                                             ["Thymosin", "PIP2"]) + " \n"

    G.add_weighted_edges_from(get_edges(CP, [Arp2_3], [Ena_Vasp, PIP2]))
    rules += "1: CP* = (Arp2_3 and not Ena_Vasp) or not PIP2 \n"

    G.add_weighted_edges_from(get_edges(Coronin, [SSH], []))
    rules += "1: Coronin* = SSH \n"

    G.add_weighted_edges_from(get_edges(ROCK, [RhoA], [SSH, Coronin]))
    rules += "1: ROCK* = RhoA and not (SSH and Coronin) \n"

    G.add_weighted_edges_from(get_edges(PKD, [ROCK], []))
    rules += "1: PKD* = ROCK \n"

    G.add_weighted_edges_from(get_edges(LIMK, [ROCK, PAK, PKD], [SSH]))
    rules += "1: LIMK* = (ROCK or PAK or PKD) and not SSH \n"

    G.add_weighted_edges_from(
        get_edges(Cofilin, [SSH, Arp2_3], [PIP2, Thymosin, LIMK, Cortactin]))
    rules += "1: Cofilin* = " + voting_rule(
        ["SSH", "Arp2_3"], ["PIP2", "Thymosin", "LIMK", "Cortactin"]) + "\n"

    G.add_weighted_edges_from(get_edges(SSH, [Coronin, Rac1], [PKD]))
    rules += "1: SSH* = (Coronin or Rac1) and not PKD \n"

    G.add_weighted_edges_from(get_edges(Actin_BR, [Arp2_3], []))
    rules += "1: Actin_BR* = Arp2_3 \n"

    G.add_weighted_edges_from(
        get_edges(Actin_ST, [Profilin, Dia1, Dia2, Ena_Vasp], [CP, Cofilin]))
    rules += "1: Actin_ST* = Profilin and (" + voting_rule(
        ["Dia1", "Dia2", "Ena_Vasp"], ["CP", "Cofilin"]) + ")\n"

    return {"rules": rules, "graph": G}
Exemplo n.º 5
0
import utils
from graph_tool.all import *
import graph_tool.flow as gt
import pickle as pk


if __name__ == "__main__":
    positions = pk.load(open("county_locations.dict"))
    positions = sorted(positions.items(), key=lambda (k, v): k)
    positions = map(lambda (k, v): (v[1], v[0]), positions)

    names = utils.get_name_map("../mississippi_county.list")
    edges = utils.get_edges("../mississippi_graph_NS.csv", names)
    # edges += utils.get_edges("../mississippi_graph_EW.csv", names)

    g = Graph()
    g.set_directed(True)
    vertices = g.add_vertex(len(names))
    cap = g.new_edge_property("double")
    pos = g.new_vertex_property("vector<double>")

    for p in range(len(positions)):
        (x, y) = positions[p]
        pos[p] = [x, -y]

    for e in edges:
        edge = g.add_edge(e[0], e[1])
        cap[edge] = e[2]

    graph_draw(
        g,
Exemplo n.º 6
0
from graph import Graph
import utils

if __name__ == "__main__":
    v, adjacency_matrix = utils.read_from_file("matrix")
    edges = utils.get_edges(adjacency_matrix)
    g = Graph(v)
    utils.add_edges(g, edges)
    g.dfs(2)
    print("-----------------------------")
    g1 = Graph(v)
    utils.add_edges(g1, edges)
    g1.bfs(4)
    print("-----------------------------")
Exemplo n.º 7
0
def build_rules():
    """ Actin network rules.
        Changes from initial model:
            * direct activation link RhoA -> Rac1
            * ROCK inhibition delay: RhoA -> ROCK -> ROCK_ -| Rac1
            * weaker RhoA inhibition rule: not Rac1 or not PAK
        Changes from v1:
            * strong inhibitors for Arp2_3 (reworked voting rule)
            * reworked rule for Cortactin
    """

    Actin_BR = "Actin_BR"
    Actin_ST = "Actin_ST"
    Arp2_3 = "Arp2_3"
    CP = "CP"
    Cdc42 = "Cdc42"
    Cofilin = "Cofilin"
    Coronin = "Coronin"
    Cortactin = "Cortactin"
    Dia1 = "Dia1"
    Dia2 = "Dia2"
    Ena_Vasp = "Ena_Vasp"
    IRSp53 = "IRSp53"
    LIMK = "LIMK"
    PAK = "PAK"
    PIP2 = "PIP2"
    PKD = "PKD"
    Profilin = "Profilin"
    ROCK = "ROCK"
    ROCK_ = "ROCK_"
    Rac1 = "Rac1"
    RhoA = "RhoA"
    SSH = "SSH"
    Thymosin = "Thymosin"
    WASP = "WASP"
    WAVE = "WAVE"

    G = nx.DiGraph()
    rules = ""

    G.add_weighted_edges_from(
        get_edges(WASP, [Rac1, Cdc42, PIP2, Cortactin, IRSp53], [Thymosin]))
    rules += "1: WASP* = not Thymosin and (Rac1 or Cdc42 or PIP2 or Cortactin or IRSp53) \n"

    G.add_weighted_edges_from(get_edges(WAVE, [Rac1], []))
    rules += "1: WAVE* = Rac1 \n"  # or IRSp53

    G.add_weighted_edges_from(
        get_edges(Arp2_3, [PAK, WASP, WAVE, Cortactin],
                  [Profilin, Thymosin, Coronin]))
    rules += "1: Arp2_3* = PAK and (" + voting_rule(
        [WASP, WAVE, Cortactin], [Profilin, Thymosin, Coronin],
        strongInhibition=False) + ")\n"

    G.add_weighted_edges_from(get_edges(Rac1, [Arp2_3, Dia1, RhoA], [ROCK_]))
    rules += "1: Rac1* = not ROCK_ and (Arp2_3 or Dia1 or RhoA) \n"  # intermediate ROCK_ node + activation from RhoA

    G.add_weighted_edges_from(get_edges(RhoA, [], [Rac1, PAK]))
    rules += "1: RhoA* = not Rac1 or not PAK \n"

    G.add_weighted_edges_from(get_edges(Thymosin, [], [WASP, Cofilin]))
    rules += "1: Thymosin* = not WASP and not Cofilin \n"

    G.add_weighted_edges_from(get_edges(Cortactin, [Rac1, PAK],
                                        [Coronin, PKD]))
    rules += "1: Cortactin* = (Rac1 and PAK) or (Rac1 and not (Coronin and PKD) ) \n"
    # rules += "1: Cortactin* = (Rac1 and not (Coronin and PKD) \n"

    G.add_weighted_edges_from(get_edges(IRSp53, [Cdc42, Rac1], []))
    rules += "1: IRSp53* = Cdc42 or Rac1 \n"

    G.add_weighted_edges_from(get_edges(PAK, [Rac1, Cdc42, PKD], []))
    rules += "1: PAK* = Rac1 or Cdc42 or PKD \n"

    G.add_weighted_edges_from(get_edges(Dia1, [RhoA], [CP]))
    rules += "1: Dia1* = RhoA and not CP \n"

    G.add_weighted_edges_from(get_edges(Dia2, [Rac1, RhoA], []))
    rules += "1: Dia2* = Rac1 or RhoA \n"

    G.add_weighted_edges_from(get_edges(Ena_Vasp, [IRSp53, WASP, PKD], []))
    rules += "1: Ena_Vasp* = IRSp53 or WASP or PKD \n"

    G.add_weighted_edges_from(
        get_edges(Profilin, [WASP, Dia1, WAVE], [Thymosin, PIP2]))
    rules += "1: Profilin* = " + voting_rule(["WASP", "Dia1", "WAVE"],
                                             ["Thymosin", "PIP2"]) + " \n"

    G.add_weighted_edges_from(get_edges(CP, [Arp2_3], [Ena_Vasp, PIP2]))
    rules += "1: CP* = (Arp2_3 and not Ena_Vasp) or not PIP2 \n"

    G.add_weighted_edges_from(get_edges(Coronin, [SSH], []))
    rules += "1: Coronin* = SSH \n"

    G.add_weighted_edges_from(get_edges(ROCK, [RhoA], [SSH, Coronin]))
    rules += "1: ROCK* = RhoA and not (SSH and Coronin) \n"

    G.add_weighted_edges_from(get_edges(ROCK_, [ROCK], []))
    rules += "1: ROCK_* = ROCK \n"

    G.add_weighted_edges_from(get_edges(PKD, [ROCK], []))
    rules += "1: PKD* = ROCK \n"

    G.add_weighted_edges_from(get_edges(LIMK, [ROCK, PAK], [SSH]))
    rules += "1: LIMK* = (ROCK or PAK) and not SSH \n"

    G.add_weighted_edges_from(
        get_edges(Cofilin, [SSH, Arp2_3], [PIP2, Thymosin, LIMK, Cortactin]))
    rules += "1: Cofilin* = " + voting_rule(
        ["SSH", "Arp2_3"], ["PIP2", "Thymosin", "LIMK", "Cortactin"]) + "\n"

    G.add_weighted_edges_from(get_edges(SSH, [Coronin, Rac1], [PKD]))
    rules += "1: SSH* = (Coronin or Rac1) and not PKD \n"

    G.add_weighted_edges_from(get_edges(Actin_BR, [Arp2_3], []))
    rules += "1: Actin_BR* = (Arp2_3) \n"  # or Cofilin) and not Thymosin

    G.add_weighted_edges_from(
        get_edges(Actin_ST, [Profilin, Dia1, Dia2, Ena_Vasp], [CP, Cofilin]))
    rules += "1: Actin_ST* = Profilin and (" + voting_rule(
        ["Dia1", "Dia2", "Ena_Vasp"], ["CP", "Cofilin"]) + ")\n"

    return {"rules": rules, "graph": G}
Exemplo n.º 8
0
        cnets_masks[i][j] = tmp

print('cross_network mask done')

#print(maskes[0])
dmgc = DMGC(dims=config, n_clusters=n_clusters, init=glorot)

print('build model done')

u_is = []
u_js = []
u_labels = []

for i in range(n_networks):
    G = Gs[i]
    u_i, u_j, u_label = get_edges(G)
    u_is.append(u_i)
    u_js.append(u_j)
    u_labels.append(u_label)

print('prepare to feed data')
dmgc.feedData(adjs,
              maskes,
              xs,
              cnets,
              cnets_masks,
              u_js=u_js,
              u_is=u_is,
              u_labels=u_labels)

print('feed data done')
Exemplo n.º 9
0
def build_rules():
    """ Example network rules for validation.
    """
    egf = "egf"
    nrg1 = "nrg1"
    erbb1 = "erbb1"
    erbb2 = "erbb2"
    erbb3 = "erbb3"
    erbb11 = "erbb11"
    erbb13 = "erbb13"
    erbb23 = "erbb23"
    grb2 = "grb2"
    gab1 = "gab1"
    pi3k = "pi3k"
    sos = "sos"
    ras = "ras"
    mek = "mek"
    erk = "erk"
    pip3 = "pip3"
    akt = "akt"

    G = nx.DiGraph()
    rules = ""

    G.add_weighted_edges_from(get_edges(erbb11, [egf, erbb1], []))
    rules += "1: erbb11* = egf and erbb1\n"

    G.add_weighted_edges_from(
        get_edges(erbb13, [egf, erbb1, erbb3, nrg1], [erbb2]))
    rules += "1: erbb13* = (egf and erbb1 and not erbb2 and erbb3) or (erbb1 and not erbb2 and erbb3 and nrg1) \n"

    G.add_weighted_edges_from(get_edges(erbb23, [erbb2, erbb3, nrg1], []))
    rules += "1: erbb23* = erbb2 and erbb3 and nrg1 \n"

    G.add_weighted_edges_from(get_edges(grb2, [erbb11, erbb13, erbb23], []))
    rules += "1: grb2* = erbb11 or erbb13 or erbb23\n"

    G.add_weighted_edges_from(get_edges(gab1, [grb2, pip3], []))
    rules += "1: gab1* = grb2 and pip3 \n"

    G.add_weighted_edges_from(get_edges(pi3k, [erbb13, erbb23, gab1, ras], []))
    rules += "1: pi3k* = erbb13 or erbb23 or gab1 or ras \n"

    G.add_weighted_edges_from(get_edges(sos, [grb2], [erk]))
    rules += "1: sos* = grb2 and not erk\n"

    G.add_weighted_edges_from(get_edges(ras, [sos], []))
    rules += "1: ras* = sos\n"

    G.add_weighted_edges_from(get_edges(mek, [ras], []))
    rules += "1: mek* = ras\n"

    G.add_weighted_edges_from(get_edges(erk, [mek], []))
    rules += "1: erk* = mek\n"

    G.add_weighted_edges_from(get_edges(pip3, [pi3k], []))
    rules += "1: pip3* = pi3k\n"

    G.add_weighted_edges_from(get_edges(akt, [pip3], []))
    rules += "1: akt* = pip3\n"

    return {"rules": rules, "graph": G}
Exemplo n.º 10
0
def build_rules():
    """ Original Actin network rules.
    """
    
    Actin_BR = "Actin_BR"
    Actin_ST = "Actin_ST"
    Arp2_3 = "Arp2_3"
    CP = "CP"
    Cdc42 = "Cdc42"
    Cofilin = "Cofilin"
    Coronin = "Coronin"
    Cortactin = "Cortactin"
    Dia1 = "Dia1"
    Dia2 = "Dia2"
    Ena_Vasp = "Ena_Vasp"
    IRSp53 = "IRSp53"
    LIMK = "LIMK"
    PAK = "PAK"
    PIP2 = "PIP2"
    PKD = "PKD"
    Profilin = "Profilin"
    ROCK = "ROCK"
    Rac1 = "Rac1"
    RhoA = "RhoA"
    SSH = "SSH"
    Thymosin = "Thymosin"
    WASP = "WASP"
    WAVE = "WAVE"

    G = nx.DiGraph()
    rules = ""

    G.add_weighted_edges_from(get_edges(WASP, [Rac1, Cdc42, PIP2, Cortactin, IRSp53], [Thymosin]))
    rules += "1: WASP* = not Thymosin and (Rac1 or Cdc42 or PIP2 or Cortactin or IRSp53) \n"

    G.add_weighted_edges_from(get_edges(WAVE, [Rac1], []))
    rules += "1: WAVE* = Rac1 \n"  # or IRSp53

    G.add_weighted_edges_from(get_edges(Arp2_3, [PAK, WASP, WAVE, Cortactin], [Profilin, Thymosin, Coronin]))
    rules += "1: Arp2_3* = PAK and (" + voting_rule([WASP, WAVE, Cortactin],
                                                         [Profilin, Thymosin, Coronin]) + ")\n"

    G.add_weighted_edges_from(get_edges(Rac1, [Arp2_3, Dia1, RhoA], [ROCK]))
    rules += "1: Rac1* = not ROCK and (Arp2_3 or Dia1) \n"

    G.add_weighted_edges_from(get_edges(RhoA, [], [Rac1, PAK]))
    rules += "1: RhoA* = not Rac1 and not PAK \n"

    G.add_weighted_edges_from(get_edges(Thymosin, [], [WASP, Cofilin]))
    rules += "1: Thymosin* = not WASP and not Cofilin \n"

    G.add_weighted_edges_from(get_edges(Cortactin, [Rac1, PAK], [Coronin, PKD]))
    rules += "1: Cortactin* = (Rac1 and PAK) or ((Rac1 or PAK) and not (Coronin and PKD)) \n"  # voting

    G.add_weighted_edges_from(get_edges(IRSp53, [Cdc42, Rac1], []))
    rules += "1: IRSp53* = Cdc42 or Rac1 \n"

    G.add_weighted_edges_from(get_edges(PAK, [Rac1, Cdc42, PKD], []))
    rules += "1: PAK* = Rac1 or Cdc42 or PKD \n"

    G.add_weighted_edges_from(get_edges(Dia1, [RhoA], [CP]))
    rules += "1: Dia1* = RhoA and not CP \n"

    G.add_weighted_edges_from(get_edges(Dia2, [Rac1, RhoA], []))
    rules += "1: Dia2* = Rac1 or RhoA \n"

    G.add_weighted_edges_from(get_edges(Ena_Vasp, [IRSp53, WASP, PKD], []))
    rules += "1: Ena_Vasp* = IRSp53 or WASP or PKD \n"

    G.add_weighted_edges_from(get_edges(Profilin, [WASP, Dia1, WAVE], [Thymosin, PIP2]))
    rules += "1: Profilin* = " + voting_rule(["WASP", "Dia1", "WAVE"], ["Thymosin", "PIP2"]) + " \n"

    G.add_weighted_edges_from(get_edges(CP, [Arp2_3], [Ena_Vasp, PIP2]))
    rules += "1: CP* = (Arp2_3 and not Ena_Vasp) or not PIP2 \n"

    G.add_weighted_edges_from(get_edges(Coronin, [SSH], []))
    rules += "1: Coronin* = SSH \n"

    G.add_weighted_edges_from(get_edges(ROCK, [RhoA], [SSH, Coronin]))
    rules += "1: ROCK* = RhoA and not (SSH and Coronin) \n"

    G.add_weighted_edges_from(get_edges(PKD, [ROCK], []))
    rules += "1: PKD* = ROCK \n"

    G.add_weighted_edges_from(get_edges(LIMK, [ROCK, PAK], [SSH]))
    rules += "1: LIMK* = (ROCK or PAK) and not SSH \n"

    G.add_weighted_edges_from(get_edges(Cofilin, [SSH, Arp2_3], [PIP2, Thymosin, LIMK, Cortactin]))
    rules += "1: Cofilin* = " + voting_rule(["SSH", "Arp2_3"],
                                                 ["PIP2", "Thymosin", "LIMK", "Cortactin"]) + "\n"

    G.add_weighted_edges_from(get_edges(SSH, [Coronin, Rac1], [PKD]))
    rules += "1: SSH* = (Coronin or Rac1) and not PKD \n"

    G.add_weighted_edges_from(get_edges(Actin_BR, [Arp2_3], []))
    rules += "1: Actin_BR* = (Arp2_3) \n"  # or Cofilin) and not Thymosin

    G.add_weighted_edges_from(get_edges(Actin_ST, [Profilin, Dia1, Dia2, Ena_Vasp], [CP, Cofilin]))
    rules += "1: Actin_ST* = Profilin and (" + voting_rule(["Dia1", "Dia2", "Ena_Vasp"],
                                                                ["CP", "Cofilin"]) + ")\n"

    return {"rules":rules, "graph":G}