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:
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¶
graphistry.layout.graph.edgeBase module¶
graphistry.layout.graph.graph module¶

class
graphistry.layout.graph.graph.
Graph
(vertices=None, edges=None, directed=True)¶ Bases:
object
The graph is stored in disjointsets holding each connected component in components as a list of graph_core objects.
 Attributes
C (list[GraphBase]): list of graph_core components.
 Methods
add_vertex(v): add vertex v into the Graph as a new component add_edge(e): add edge e and its vertices into the Graph possibly merging the associated graph_core components get_vertices_count(): see order() vertices(): see graph_core edges(): see graph_core remove_edge(e): remove edge e possibly spawning two new cores if the graph_core that contained e gets disconnected. remove_vertex(v): remove vertex v and all its edges. order(): the order of the graph (number of vertices) norm(): the norm of the graph (number of edges) deg_min(): the minimum degree of vertices deg_max(): the maximum degree of vertices deg_avg(): the average degree of vertices eps(): the graph epsilon value (norm/order), average number of edges per vertex. connected(): returns True if the graph is connected (i.e. it has only one component). components(): returns the list of components

N
(v, f_io=0)¶

add_edge
(e)¶

add_edges
(edges)¶  Parameters
edges (
List
) –

add_vertex
(v)¶

component_class
¶

connected
()¶

deg_avg
()¶

deg_max
()¶

deg_min
()¶

edges
()¶

eps
()¶

get_vertex_from_data
(data)¶

get_vertices_count
()¶

norm
()¶

order
()¶

path
(x, y, f_io=0, hook=None)¶

remove_edge
(e)¶

remove_vertex
(x)¶

vertices
()¶
graphistry.layout.graph.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.
 Methods:
vertices(cond=None): generates an iterator over vertices, with optional filter edges(cond=None): generates an iterator over edges, with optional filter matrix(cond=None): returns the associativity matrix of the graph component order(): the order of the graph (number of vertices) norm(): the norm of the graph (number of edges) deg_min(): the minimum degree of vertices deg_max(): the maximum degree of vertices deg_avg(): the average degree of vertices eps(): the graph epsilon value (norm/order), average number of edges per vertex. 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. roots(): returns the list of roots (vertices with no inward edges). leaves(): returns the list of leaves (vertices with no outward edges). add_single_vertex(v): allow a GraphBase to hold a single vertex. add_edge(e): add edge e. At least one of its vertex must belong to the graph, the other being added automatically. remove_edge(e): remove Edge e, asserting that the resulting graph is still connex. remove_vertex(x): remove Vertex x and all associated edges. 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. get_scs_with_feedback(): 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). partition(): returns a partition of the connected graph as a list of lists. neighbors(v): returns neighbours of a vertex v.

N
(v, f_io=0)¶

add_edge
(e)¶

add_single_vertex
(v)¶

complement
(G)¶

constant_function
(value)¶

contract
(e)¶

deg_avg
()¶

deg_max
()¶

deg_min
()¶

dft
(start_vertex=None)¶

dijkstra
(x, f_io=0, hook=None)¶

edges
(cond=None)¶

eps
()¶

get_scs_with_feedback
(roots=None)¶ Minimum FAS algorithm (feedback arc set) creating a DAG.
 Parameters
roots –
 Returns

leaves
()¶

matrix
(cond=None)¶ This associativity matrix is like the adjacency matrix but antisymmetric.
 Parameters
cond – same a the condition function in vertices().
 Returns
array

norm
()¶ The size of the edge poset.

order
()¶

partition
()¶

path
(x, y, f_io=0, hook=None)¶

remove_edge
(e)¶

remove_vertex
(x)¶

roots
()¶

spans
(vertices)¶

union_update
(G)¶

vertices
(cond=None)¶
graphistry.layout.graph.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
¶
graphistry.layout.graph.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.
 Methods
degree() : degree of the vertex (number of edges). e_in() : list of edges directed toward this vertex. e_out(): list of edges directed outward this vertex. e_dir(int): either e_in, e_out or all edges depending on provided direction parameter (>0 means outward). neighbors(f_io=0): list of neighbor vertices in all directions (default) or in filtered f_io direction (>0 means outward). e_to(v): returns the Edge from this vertex directed toward vertex v. e_from(v): returns the Edge from vertex v directed toward this vertex. e_with(v): return the Edge with both this vertex and vertex v detach(): removes this vertex from all its edges and returns this list of edges.

degree
()¶

detach
()¶

e_dir
(dir)¶

e_from
(x)¶

e_in
()¶

e_out
()¶

e_to
(y)¶

e_with
(v)¶

neighbors
(direction=0)¶ Returns the neighbors of this vertex.
 Parameters
direction –
0: parent and children
1: parents
+1: children
 Returns
list of vertices