edge Module¶

class
graphistry.layout.graph.edge.
Edge
(x, y, w=1, data=None, connect=False) Bases:
graphistry.layout.graph.edgeBase.EdgeBase
A graph edge.
 Attributes
data (object): an optional payload
w (int): an optional weight associated with the edge (default 1) used by Dijkstra to find minflow paths.
feedback (bool): whether the Tarjan algorithm has inverted this edge to decycle the graph.

attach
() Attach this edge to the edge collections of the vertices.

data
: object

detach
() Removes this edge from the edge collections of the vertices.

feedback
: bool

w
: int
edgeBase Module¶

class
graphistry.layout.graph.edgeBase.
EdgeBase
(x, y) Bases:
object
Base class for edges.
 Attributes
degree (int): degree of the edge (number of unique vertices).
v (list[Vertex]): list of vertices associated with this edge.

degree
: int Is 0 if a loop, otherwise 1.
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

component_class

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

graphBase Module¶

class
graphistry.layout.graph.graphBase.
GraphBase
(vertices=None, edges=None, directed=True) Bases:
object
A 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 weightededges 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 breadthfirst 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
vertex Module¶

class
graphistry.layout.graph.vertex.
Vertex
(data=None) Bases:
graphistry.layout.graph.vertexBase.VertexBase
Vertex class enhancing a VertexBase with graphrelated 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
vertexBase Module¶

class
graphistry.layout.graph.vertexBase.
VertexBase
Bases:
object
Base 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