graphistry.layout.graph package#
Submodules#
graphistry.layout.graph.edge module#
- class graphistry.layout.graph.edge.Edge(x, y, w=1, data=None, connect=False)#
Bases:
EdgeBaseA graph edge.
- Attributes
data (object): an optional payload
w (int): an optional weight associated with the edge (default 1) used by Dijkstra to find min-flow paths.
feedback (bool): whether the Tarjan algorithm has inverted this edge to de-cycle the graph.
- Parameters:
w (int)
data (object)
- attach()#
Attach this edge to the edge collections of the vertices.
- data: object#
- degree: int#
Is 0 if a loop, otherwise 1.
- detach()#
Removes this edge from the edge collections of the vertices.
- feedback: bool#
- w: int#
graphistry.layout.graph.edgeBase module#
graphistry.layout.graph.graph module#
- class graphistry.layout.graph.graph.Graph(vertices=None, edges=None, directed=True)#
Bases:
object- N(v, f_io=0)#
- add_edge(e)#
add edge e and its vertices into the Graph possibly merging the associated graph_core components
- add_edges(edges)#
- Parameters:
edges (List)
- add_vertex(v)#
add vertex v into the Graph as a new component
- connected()#
returns the list of components
- deg_avg()#
the average degree of vertices
- deg_max()#
the maximum degree of vertices
- deg_min()#
the minimum degree of vertices
- edges()#
- eps()#
the graph epsilon value (norm/order), average number of edges per vertex.
- get_vertex_from_data(data)#
- get_vertices_count()#
- norm()#
the norm of the graph (number of edges)
- order()#
the order of the graph (number of vertices)
- path(x, y, f_io=0, hook=None)#
- remove_edge(e)#
remove edge e possibly spawning two new cores if the graph_core that contained e gets disconnected.
- remove_vertex(x)#
remove vertex v and all its edges.
- vertices()#
see graph_core
graphistry.layout.graph.graphBase module#
- class graphistry.layout.graph.graphBase.GraphBase(vertices=None, edges=None, directed=True)#
Bases:
objectA connected graph of Vertex/Edge objects. A GraphBase is a component of a Graph that contains a connected set of Vertex and Edges.
- Attributes:
verticesPoset (Poset[Vertex]): the partially ordered set of vertices of the graph. edgesPoset (Poset[Edge]): the partially ordered set of edges of the graph. loops (set[Edge]): the set of loop edges (of degree 0). directed (bool): indicates if the graph is considered oriented or not.
- N(v, f_io=0)#
- add_edge(e)#
add edge e. At least one of its vertex must belong to the graph, the other being added automatically.
- add_single_vertex(v)#
allow a GraphBase to hold a single vertex.
- complement(G)#
- constant_function(value)#
- contract(e)#
- deg_avg()#
the average degree of vertices
- deg_max()#
the maximum degree of vertices
- deg_min()#
the minimum degree of vertices
- dft(start_vertex=None)#
- dijkstra(x, f_io=0, hook=None)#
shortest weighted-edges paths between x and all other vertices by dijkstra’s algorithm with heap used as priority queue.
- edges(cond=None)#
generates an iterator over edges, with optional filter
- eps()#
the graph epsilon value (norm/order), average number of edges per vertex.
- get_scs_with_feedback(roots=None)#
Minimum FAS algorithm (feedback arc set) creating a DAG. Returns the set of strongly connected components (“scs”) by using Tarjan algorithm. These are maximal sets of vertices such that there is a path from each vertex to every other vertex. The algorithm performs a DFS from the provided list of root vertices. A cycle is of course a strongly connected component,but a strongly connected component can include several cycles. The Feedback Acyclic Set of edge to be removed/reversed is provided by marking the edges with a “feedback” flag. Complexity is O(V+E).
- Parameters:
roots
- Returns:
- leaves()#
returns the list of leaves (vertices with no outward edges).
- matrix(cond=None)#
This associativity matrix is like the adjacency matrix but antisymmetric. Returns the associativity matrix of the graph component
- Parameters:
cond – same a the condition function in vertices().
- Returns:
array
- norm()#
The size of the edge poset (number of edges).
- order()#
the order of the graph (number of vertices)
- partition()#
- path(x, y, f_io=0, hook=None)#
shortest path between vertices x and y by breadth-first descent, contrained by f_io direction if provided. The path is returned as a list of Vertex objects. If a hook function is provided, it is called at every vertex added to the path, passing the vertex object as argument.
- remove_edge(e)#
remove Edge e, asserting that the resulting graph is still connex.
- remove_vertex(x)#
remove Vertex x and all associated edges.
- roots()#
returns the list of roots (vertices with no inward edges).
- spans(vertices)#
- union_update(G)#
- vertices(cond=None)#
generates an iterator over vertices, with optional filter
graphistry.layout.graph.vertex module#
- class graphistry.layout.graph.vertex.Vertex(data=None)#
Bases:
VertexBaseVertex class enhancing a VertexBase with graph-related features.
- Attributes
component (GraphBase): the component of connected vertices that contains this vertex. By default, a vertex belongs no component but when it is added in a graph, c points to the connected component in this graph. data (object) : an object associated with the vertex.
- property index#
graphistry.layout.graph.vertexBase module#
- class graphistry.layout.graph.vertexBase.VertexBase#
Bases:
objectBase class for vertices.
- Attributes
e (list[Edge]): list of edges associated with this vertex.
- degree()#
degree() : degree of the vertex (number of edges).
- detach()#
removes this vertex from all its edges and returns this list of edges.
- e_dir(dir)#
either e_in, e_out or all edges depending on provided direction parameter (>0 means outward).
- e_from(x)#
returns the Edge from vertex v directed toward this vertex.
- e_in()#
e_in() : list of edges directed toward this vertex.
- e_out()#
e_out(): list of edges directed outward this vertex.
- e_to(y)#
returns the Edge from this vertex directed toward vertex v.
- e_with(v)#
return the Edge with both this vertex and vertex v
- neighbors(direction=0)#
Returns the neighbors of this vertex. List of neighbor vertices in all directions (default) or in filtered f_io direction (>0 means outward).
- Parameters:
direction –
0: parent and children
-1: parents
+1: children
- Returns:
list of vertices