Skip to content
Matthew Stern edited this page Mar 28, 2021 · 23 revisions

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

>>> v = g.set_vertex(id, vertex_function, vertex1_variables)

Remove a vertex

>>> g.remove_vertex(id)

Create an edge between vertices with id1 and id2

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

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[0]
>>> edge_2_to_1 = bi_e[0]

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.

>>> vr = topylogic.vertex_result(var1, var2)
>>> g.run([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()
Clone this wiki locally