Home | Trees | Indices | Help |
|
---|
|
object --+ | GraphBase --+ | Graph
Generic graph.
This class is built on top of GraphBase, so the order of the methods in the Epydoc
documentation is a little bit obscure: inherited methods come after the
ones implemented directly in the subclass. Graph provides many
functions that GraphBase does not, mostly because these functions are
not speed critical and they were easier to implement in Python than in
pure C. An example is the attribute handling in the constructor: the
constructor of Graph
accepts three dictionaries corresponding to the graph, vertex and edge
attributes while the constructor of GraphBase does not. This extension was needed to make Graph serializable
through the pickle
module.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
_format_mapping =
|
|||
_layout_mapping =
|
|
|||
es The edge sequence of the graph |
|||
vs The vertex sequence of the graph |
|||
Inherited from |
|
Unified reading function for graphs. This method tries to identify the format of the graph given in the first parameter and calls the corresponding reader method. The remaining arguments are passed to the reader method without any changes.
|
Unified reading function for graphs. This method tries to identify the format of the graph given in the first parameter and calls the corresponding reader method. The remaining arguments are passed to the reader method without any changes.
|
Constructs a graph based on an adjacency matrix from the given file Additional positional and keyword arguments not mentioned here are passed intact to Graph.Adjacency.
|
Reads a graph from a zipped GraphML file.
|
Reads a graph from Python pickled format
|
Copies the graph and extends the copy depending on the type of the other object given.
|
Coercion rules. This method is needed to allow the graph to react to additions with lists, tuples, integers, vertices, edges and so on. |
In-place addition (disjoint union). See Also: __add__ |
Constructs a graph from scratch.
|
In-place subtraction (difference). See Also: __sub__ |
Copies exact replicas of the original graph an arbitrary number of times.
|
Plots the graph to the given Cairo context in the given bounding box The visual style of vertices and edges can be modified at three places in the following order of precedence (lower indices override higher indices):
E.g., if the Besides the usual self-explanatory plotting parameters
(
|
Support for pickling.
|
Removes the given object(s) from the graph
|
Tries to identify the format of the graph stored in the file with the given filename. It identifies most file formats based on the extension of the file (and not on syntactic evaluation). The only exception is the adjacency matrix format and the edge list format: the first few lines of the file are evaluated to decide between the two.
Note: Internal function, should not be called directly. |
Calculates the edge connectivity of the graph or between some vertices. The edge connectivity between two given vertices is the number of edges that have to be removed in order to disconnect the two vertices into two separate components. This is also the number of edge disjoint directed paths between the vertices. The edge connectivity of the graph is the minimal edge connectivity over all vertex pairs. This method calculates the edge connectivity of a given vertex pair if both the source and target vertices are given. If none of them is given (or they are both negative), the overall edge connectivity is returned.
|
Returns the independence number of the graph. The independence number of the graph is the size of the largest independent vertex set. See Also: largest_independent_vertex_sets() for the largest independent vertex sets |
Calculates the biconnected components of the graph.
|
Calculates the biconnected components of the graph.
|
Calculates the (strong or weak) clusters (connected components) for a given graph.
|
Calculates the vertex connectivity of the graph or between some vertices. The vertex connectivity between two given vertices is the number of vertices that have to be removed in order to disconnect the two vertices into two separate components. This is also the number of vertex disjoint directed paths between the vertices (apart from the source and target vertices of course). The vertex connectivity of the graph is the minimal vertex connectivity over all vertex pairs. This method calculates the vertex connectivity of a given vertex pair if both the source and target vertices are given. If none of them is given (or they are both negative), the overall vertex connectivity is returned.
|
Community structure based on the betweenness of the edges in the network. The idea is that the betweenness of the edges connecting two communities is typically high, as many of the shortest paths between nodes in separate communities go through them. So we gradually remove the edge with the highest betweenness and recalculate the betweennesses after every removal. This way sooner or later the network falls of to separate components. The result of the clustering will be represented by a dendrogram.
|
Community structure based on the greedy optimization of modularity. This algorithm merges individual nodes into communities in a way that greedily maximizes the modularity score of the graph. It can be proven that if no merge can increase the current modularity score, the algorithm can be stopped since no further increase can be achieved. This algorithm is said to run almost in linear time on sparse graphs.
Reference: A Clauset, MEJ Newman and C Moore: Finding community structure in very large networks. Phys Rev E 70, 066111 (2004). |
Newman's leading eigenvector method for detecting community structure. This is the proper implementation of the recursive, divisive algorithm: each split is done by maximizing the modularity regarding the original network.
Reference: MEJ Newman: Finding community structure in networks using the eigenvectors of matrices, arXiv:physics/0605087 |
A naive implementation of Newman's eigenvector community structure detection. This function splits the network into two components according to the leading eigenvector of the modularity matrix and then recursively takes the given number of steps by splitting the communities as individual networks. This is not the correct way, however, see the reference for explanation. Consider using the correct community_leading_eigenvector method instead.
Reference: MEJ Newman: Finding community structure in networks using the eigenvectors of matrices, arXiv:physics/0605087 |
Community detection algorithm of Latapy & Pons, based on random walks. The basic idea of the algorithm is that short random walks tend to stay in the same community. The result of the clustering will be represented as a dendrogram.
Reference: Pascal Pons, Matthieu Latapy: Computing communities in large networks using random walks, http://arxiv.org/abs/physics/0512106. |
Calculates the (strong or weak) clusters (connected components) for a given graph.
|
Returns the list of articulation points in the graph. A vertex is an articulation point if its removal increases the number of connected components in the graph. |
Calculates the degree distribution of the graph. Unknown keyword arguments are directly passed to degree().
|
Deletes some edges from the graph. The set of edges to be deleted is determined by the positional and keyword arguments. If any keyword argument is present, or the first positional argument is callable, an edge sequence is derived by calling EdgeSeq.select with the same positional and keyword arguments. Edges in the derived edge sequence will be removed. Otherwise the first positional argument is considered as follows:
|
Calculates the dyad census of the graph. Dyad census means classifying each pair of vertices of a directed graph into three categories: mutual (there is an edge from a to b and also from b to a), asymmetric (there is an edge from a to b or from b to a but not the other way round) and null (there is no connection between a and b).
Reference: Holland, P.W. and Leinhardt, S. (1970). A Method for Detecting Structure in Sociometric Data. American Journal of Sociology, 70, 492-513. |
Calculates eccentricities for vertices with the given indices. Eccentricity is given as the reciprocal of the greatest distance between the vertex being considered and any other vertex in the graph. Please note that for any unconnected graph, eccentricities will all be equal to 1 over the number of vertices, since for all vertices the greatest distance will be equal to the number of vertices (this is how shortest_paths denotes vertex pairs where it is impossible to reach one from the other).
|
Calculates the edge connectivity of the graph or between some vertices. The edge connectivity between two given vertices is the number of edges that have to be removed in order to disconnect the two vertices into two separate components. This is also the number of edge disjoint directed paths between the vertices. The edge connectivity of the graph is the minimal edge connectivity over all vertex pairs. This method calculates the edge connectivity of a given vertex pair if both the source and target vertices are given. If none of them is given (or they are both negative), the overall edge connectivity is returned.
|
Calculates the eigenvector centralities of the vertices in a graph.
|
Returns the adjacency matrix of a graph.
|
Returns the adjacency edge list representation of the graph. The adjacency edge list representation is a list of lists. Each item of the outer list belongs to a single vertex of the graph. The inner list contains the IDs of the adjacent edges of the given vertex. |
Returns the adjacency list representation of the graph. The adjacency list representation is a list of lists. Each item of the outer list belongs to a single vertex of the graph. The inner list contains the neighbors of the given vertex. |
Returns all automorphisms of the graph
|
Returns the in-degrees in a list. See degree for possible arguments. |
Returns some k-cores of the graph. The method accepts an arbitrary number of arguments representing the desired indices of the k-cores to be returned. The arguments can also be lists or tuples. The result is a single Graph object if an only integer argument was given, otherwise the result is a list of Graph objects representing the desired k-cores in the order the arguments were specified. If no argument is given, returns all k-cores in increasing order of k. |
Returns the layout of the graph according to a layout algorithm. Parameters and keyword arguments not specified here are passed to the layout algorithm directly. See the documentation of the layout algorithms for the explanation of these parameters. Registered layout names understood by this method are:
|
Returns a minimum cut in an undirected graph.
|
Calculates the modularity score of the graph with respect to a given clustering. The modularity of a graph w.r.t. some division measures how good the
division is, or how separated are the different vertex types from each
other. It is defined as Q=1/(2m)*sum(Aij-ki*kj/(2m)delta(ci,cj),i,j). m is the number of edges, Aij is the
element of the A adjacency matrix in row i and column j, ki is the degree of node i, kj is the degree of node j, and Ci and If edge weights are given, the definition of modularity is modified as follows: Aij becomes the weight of the corresponding edge, ki is the total weight of edges adjacent to vertex i, kj is the total weight of edges adjacent to vertex j and m is the total edge weight in the graph.
Reference: MEJ Newman and M Girvan: Finding and evaluating community structure in networks. Phys Rev E 69 026113, 2004. |
Returns the clique number of the graph. The clique number of the graph is the size of the largest clique. See Also: largest_cliques() for the largest cliques. |
Returns the out-degrees in a list. See degree for possible arguments. |
Returns the path length histogram of the graph
|
Unified writing function for graphs. This method tries to identify the format of the graph given in the first parameter (based on extension) and calls the corresponding writer method. The remaining arguments are passed to the writer method without any changes.
|
Finds the coreness (shell index) of the vertices of the network. The k-core of a graph is a maximal subgraph in which each vertex has at least degree k. (Degree here means the degree in the subgraph of course). The coreness of a vertex is k if it is a member of the k-core but not a member of the k+1-core.
Reference: Vladimir Batagelj, Matjaz Zaversnik: An O(m) Algorithm for Core Decomposition of Networks. |
Calculates shortest path lengths for given nodes in a graph.
|
Returns basic statistics about the graph in a string
|
Calculates the triad census of the graph.
Reference: Davis, J.A. and Leinhardt, S. (1972). The Structure of Positive Interpersonal Relations in Small Groups. In: J. Berger (Ed.), Sociological Theories in Progress, Volume 2, 218-251. Boston: Houghton Mifflin. |
Calculates the vertex connectivity of the graph or between some vertices. The vertex connectivity between two given vertices is the number of vertices that have to be removed in order to disconnect the two vertices into two separate components. This is also the number of vertex disjoint directed paths between the vertices (apart from the source and target vertices of course). The vertex connectivity of the graph is the minimal vertex connectivity over all vertex pairs. This method calculates the vertex connectivity of a given vertex pair if both the source and target vertices are given. If none of them is given (or they are both negative), the overall vertex connectivity is returned.
|
Unified writing function for graphs. This method tries to identify the format of the graph given in the first parameter (based on extension) and calls the corresponding writer method. The remaining arguments are passed to the writer method without any changes.
|
Writes the adjacency matrix of the graph to the given file All the remaining arguments not mentioned here are passed intact to Graph.get_adjacency.
|
Writes the graph to a zipped GraphML file. The library uses the gzip compression algorithm, so the resulting file
can be unzipped with regular gzip uncompression (like Uses a temporary file to store intermediate GraphML data, so make sure you have enough free space to store the unzipped GraphML file as well.
|
Saves the graph in Python pickled format
|
Saves the graph as an SVG (Scalable Vector Graphics) file
|
|
_format_mapping
|
_layout_mapping
|
|
esThe edge sequence of the graph
|
vsThe vertex sequence of the graph
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Aug 16 21:30:46 2008 | http://epydoc.sourceforge.net |