Graph - mstern98/topylogic-git GitHub Wiki

Graph

graph(max_state_change = -1,
      snapshot_timestamp = topylogic.START_STOP,
      max_loop = topylogic.MAX_LOOPS,
      lvl_verbose = topylogic.VERTICES + topylogic.EDGES + topylogic.FUNCTIONS + topylogic.GLOBALS,
      context = topylogic.SINGLE,
      mem_option = topylogic.CONTINUE
      request_flag = topylogic.IGNORE_FAIL_REQUEST)

Create a graph

>>> g = topylogic.graph()

Create a vertex Note: Should you set vertex_function to None, you must do v.set_callback(vertex_function) else the program will fail.

>>> v = g.set_vertex(id, vertex_function=None, vertex_glbl=None)

Get the vertex in the graph

>>> v = g.vertex(id)

Get the set of vertices connected to a vertex with an id

>>> vertices = g.vertices_connected_to(id)

Get all vertices in the graph

>>> vertices = g.get_vertices()

Get the set of edges connected from a vertex with an id

>>> edges = g.edges_connected_to(id)

Remove a vertex

>>> g.remove_vertex(id)

Create an edge between vertices with id1 and id2 Note: Should you set edge_function to None, you must do e.set_callback(edge_function) else the program will fail.

>>> e = g.set_edge(id1, id2, edge_function=None, edge_glbl=None)

Get the edge in the graph that connects a vertex a to b with their id's

>>> e = g.edge(id1, id2)

Get all edges in the graph

>>> edges = g.get_edges()

Remove an edge between vertex a and b

>>> g.remove_edge(id_a, id_b)

Create a bi directional edge between vertices with id1 and id2

>>> bi_e = g.set_bi_edge(id1, id2, edge_function, edge_variables)
>>> edge_1_to_2 = bi_e.edge_a_to_b
>>> edge_2_to_1 = bi_e.edge_b_to_a

Get the bi edge in the graph that connects a vertex a to b with their id's

>>> bi_e = g.bi_edge(id1, id2)

Remove a bi-directional edge between vertex a and b

>>> g.remove_bi_edge(id_a, id_b)

Set the starting state of one vertex

>>> v1 = g.set_vertex(id1, vertex_function, vertex1_variables)
>>> v2 = g.set_vertex(id2, another_vertex_function, vertex2_variables)
>>> e = g.set_edge(id1, id2, edge_function, edge_variables)
>>> g.set_starting_vertex(id1)

Set the starting state set using the id's of the vertices

>>> v1 = g.set_vertex(id1, vertex_function, vertex1_variables)
>>> v2 = g.set_vertex(id2, another_vertex_function, vertex2_variables)
>>> e = g.set_edge(id1, id2, edge_function, edge_variables)
>>> g.set_starting_vertices([id1, id2])

Run the graph. The number of vertex results passed to run must be equal to the number of vertices in the starting set.

>>> vr1 = topylogic.vertex_result(var1, var2)
>>> vr2 = topylogic.vertex_result(var3, var4)
>>> g.run([vr1, vr2])

Run the graph. Run only one vertex.

>>> vr = topylogic.vertex_result(var1, var2)
>>> g.run_one(vr)

Submit a request

>>> g.submit_request(request_type, request)

Submit a generic request (one that simply calls a function)

>>> def f(args):
        #Do something
>>> g.submit_generic_request(args, f)

Process requests (you shouldn't need to call this)

>>> g.process_requests()

Pause the graph

>>> g.pause_graph()

Resume the graph

>>> g.resume_graph()

Destroy a graph

>>> g.destroy()
⚠️ **GitHub.com Fallback** ⚠️