class documentation

Generic graph.

This class is built on top of GraphBase, so the order of the methods in the generated API 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. Graph also overrides some functions from GraphBase to provide a more convenient interface; e.g., layout functions return a Layout instance from Graph instead of a list of coordinate pairs.

Graphs can also be indexed by strings or pairs of vertex indices or vertex names. When a graph is indexed by a string, the operation translates to the retrieval, creation, modification or deletion of a graph attribute:

>>> g = Graph.Full(3)
>>> g["name"] = "Triangle graph"
>>> g["name"]
'Triangle graph'
>>> del g["name"]

When a graph is indexed by a pair of vertex indices or names, the graph itself is treated as an adjacency matrix and the corresponding cell of the matrix is returned:

>>> g = Graph.Full(3)
>>> g.vs["name"] = ["A", "B", "C"]
>>> g[1, 2]
1
>>> g["A", "B"]
1
>>> g["A", "B"] = 0
>>> g.ecount()
2

Assigning values different from zero or one to the adjacency matrix will be translated to one, unless the graph is weighted, in which case the numbers will be treated as weights:

>>> g.is_weighted()
False
>>> g["A", "B"] = 2
>>> g["A", "B"]
1
>>> g.es["weight"] = 1.0
>>> g.is_weighted()
True
>>> g["A", "B"] = 2
>>> g["A", "B"]
2
>>> g.es["weight"]
[1.0, 1.0, 2]
Class Method Incidence Deprecated alias to Graph.Biadjacency().
Method __bool__ Returns True if the graph has at least one vertex, False otherwise.
Method __coerce__ Coercion rules.
Method __init__ __init__(n=0, edges=None, directed=False, graph_attrs=None, vertex_attrs=None, edge_attrs=None)
Method __reduce__ Support for pickling.
Method __str__ Returns a string representation of the graph.
Method dfs Conducts a depth first search (DFS) on the graph.
Method dyad_census Calculates the dyad census of the graph.
Method get_all_simple_paths Calculates all the simple paths from a given node to some other nodes (or all of them) in a graph.
Method get_incidence Deprecated alias to Graph.get_biadjacency().
Method is_named Returns whether the graph is named.
Method is_weighted Returns whether the graph is weighted.
Method path_length_hist Returns the path length histogram of the graph
Method spanning_tree Calculates a minimum spanning tree for a graph.
Method summary Returns the summary of the graph.
Method transitivity_avglocal_undirected Calculates the average of the vertex transitivities of the graph.
Method triad_census Calculates the triad census of the graph.
Constant GRG Undocumented
Class Variable __add__ Undocumented
Class Variable __and__ Undocumented
Class Variable __hash__ Undocumented
Class Variable __iadd__ Undocumented
Class Variable __isub__ Undocumented
Class Variable __iter__ Undocumented
Class Variable __mul__ Undocumented
Class Variable __or__ Undocumented
Class Variable __sub__ Undocumented
Class Variable Biadjacency Undocumented
Class Variable Bipartite Undocumented
Class Variable DataFrame Undocumented
Class Variable DictDict Undocumented
Class Variable DictList Undocumented
Class Variable disjoint_union Undocumented
Class Variable Formula Undocumented
Class Variable from_graph_tool Undocumented
Class Variable from_networkx Undocumented
Class Variable Full_Bipartite Undocumented
Class Variable intersection Undocumented
Class Variable ListDict Undocumented
Class Variable Random_Bipartite Undocumented
Class Variable Read Undocumented
Class Variable Read_Adjacency Undocumented
Class Variable Read_GraphMLz Undocumented
Class Variable Read_Pickle Undocumented
Class Variable Read_Picklez Undocumented
Class Variable TupleList Undocumented
Class Variable union Undocumented
Class Variable Weighted_Adjacency Undocumented
Property es The edge sequence of the graph
Property vs The vertex sequence of the graph
Class Method _reconstruct Reconstructs a Graph object from Python's pickled format.
Property _as_parameter_ Undocumented

Inherited from GraphBase:

Method __new__ Create and return a new object. See help(type) for accurate signature.
Method add_edges Adds edges to the graph.
Method add_vertices Adds vertices to the graph.
Method Adjacency Generates a graph from its adjacency matrix.
Method all_minimal_st_separators Returns a list containing all the minimal s-t separators of a graph.
Method all_st_cuts Returns all the cuts between the source and target vertices in a directed graph.
Method all_st_mincuts Returns all minimum cuts between the source and target vertices in a directed graph.
Method are_connected Decides whether two given vertices are directly connected.
Method articulation_points Returns the list of articulation points in the graph.
Method assortativity Returns the assortativity of the graph based on numeric properties of the vertices.
Method assortativity_degree Returns the assortativity of a graph based on vertex degrees.
Method assortativity_nominal Returns the assortativity of the graph based on vertex categories.
Method Asymmetric_Preference Generates a graph based on asymmetric vertex types and connection probabilities.
Method Atlas Generates a graph from the Graph Atlas.
Method attributes No summary
Method authority_score Calculates Kleinberg's authority score for the vertices of the graph
Method automorphism_group Calculates the generators of the automorphism group of a graph using the BLISS isomorphism algorithm.
Method average_path_length Calculates the average path length in a graph.
Method Barabasi Generates a graph based on the Barabasi-Albert model.
Method betweenness Calculates or estimates the betweenness of vertices in a graph.
Method bfs Conducts a breadth first search (BFS) on the graph.
Method bfsiter Constructs a breadth first search (BFS) iterator of the graph.
Method bibcoupling Calculates bibliographic coupling scores for given vertices in a graph.
Method biconnected_components Calculates the biconnected components of the graph.
Method bipartite_projection Internal function, undocumented.
Method bipartite_projection_size Internal function, undocumented.
Method bridges Returns the list of bridges in the graph.
Method canonical_permutation Calculates the canonical permutation of a graph using the BLISS isomorphism algorithm.
Method chordal_completion Returns the list of edges needed to be added to the graph to make it chordal.
Method clique_number Returns the clique number of the graph.
Method cliques Returns some or all cliques of the graph as a list of tuples.
Method closeness Calculates the closeness centralities of given vertices in a graph.
Method cocitation Calculates cocitation scores for given vertices in a graph.
Method cohesive_blocks Calculates the cohesive block structure of the graph.
Method community_edge_betweenness Community structure detection based on the betweenness of the edges in the network. This algorithm was invented by M Girvan and MEJ Newman, see: M Girvan and MEJ Newman: Community structure in social and biological networks, Proc...
Method community_fastgreedy Finds the community structure of the graph according to the algorithm of Clauset et al based on the greedy optimization of modularity.
Method community_infomap Finds the community structure of the network according to the Infomap method of Martin Rosvall and Carl T. Bergstrom.
Method community_label_propagation Finds the community structure of the graph according to the label propagation method of Raghavan et al.
Method community_leading_eigenvector A proper implementation of Newman's eigenvector community structure detection. Each split is done by maximizing the modularity regarding the original network. See the reference for details.
Method community_leiden Finds the community structure of the graph using the Leiden algorithm of Traag, van Eck & Waltman.
Method community_multilevel Finds the community structure of the graph according to the multilevel algorithm of Blondel et al. This is a bottom-up algorithm: initially every vertex belongs to a separate community, and vertices are moved between communities iteratively in a way that maximizes the vertices' local contribution to the overall modularity score...
Method community_optimal_modularity Calculates the optimal modularity score of the graph and the corresponding community structure.
Method community_spinglass Finds the community structure of the graph according to the spinglass community detection method of Reichardt & Bornholdt.
Method community_walktrap Finds the community structure of the graph according to the random walk method of Latapy & Pons.
Method complementer Returns the complementer of the graph
Method compose Returns the composition of two graphs.
Method connected_components Calculates the (strong or weak) connected components for a given graph.
Method constraint Calculates Burt's constraint scores for given vertices in a graph.
Method contract_vertices Contracts some vertices in the graph, i.e. replaces groups of vertices with single vertices. Edges are not affected.
Method convergence_degree Undocumented (yet).
Method convergence_field_size Undocumented (yet).
Method copy Creates a copy of the graph.
Method coreness Finds the coreness (shell index) of the vertices of the network.
Method count_automorphisms Calculates the number of automorphisms of a graph using the BLISS isomorphism algorithm.
Method count_isomorphisms_vf2 Determines the number of isomorphisms between the graph and another one
Method count_multiple Counts the multiplicities of the given edges.
Method count_subisomorphisms_vf2 Determines the number of subisomorphisms between the graph and another one
Method De_Bruijn Generates a de Bruijn graph with parameters (m, n)
Method decompose Decomposes the graph into subgraphs.
Method degree Returns some vertex degrees from the graph.
Method Degree_Sequence Generates a graph with a given degree sequence.
Method delete_edges Removes edges from the graph.
Method delete_vertices Deletes vertices and all its edges from the graph.
Method density Calculates the density of the graph.
Method dfsiter Constructs a depth first search (DFS) iterator of the graph.
Method diameter Calculates the diameter of the graph.
Method difference Subtracts the given graph from the original
Method distances Calculates shortest path lengths for given vertices in a graph.
Method diversity Calculates the structural diversity index of the vertices.
Method dominator Returns the dominator tree from the given root node
Method eccentricity Calculates the eccentricities of given vertices in a graph.
Method ecount Counts the number of edges.
Method edge_attributes No summary
Method edge_betweenness Calculates or estimates the edge betweennesses in a graph.
Method edge_connectivity Calculates the edge connectivity of the graph or between some vertices.
Method eigen_adjacency Undocumented
Method eigenvector_centrality Calculates the eigenvector centralities of the vertices in a graph.
Method Erdos_Renyi Generates a graph based on the Erdos-Renyi model.
Method Establishment Generates a graph based on a simple growing model with vertex types.
Method Famous Generates a famous graph based on its name.
Method farthest_points Returns two vertex IDs whose distance equals the actual diameter of the graph.
Method feedback_arc_set Calculates an approximately or exactly minimal feedback arc set.
Method Forest_Fire Generates a graph based on the forest fire model
Method Full Generates a full graph (directed or undirected, with or without loops).
Method Full_Citation Generates a full citation graph
Method fundamental_cycles Finds a single fundamental cycle basis of the graph
Method get_adjacency Returns the adjacency matrix of a graph.
Method get_all_shortest_paths Calculates all of the shortest paths from/to a given node in a graph.
Method get_biadjacency Internal function, undocumented.
Method get_diameter Returns a path with the actual diameter of the graph.
Method get_edgelist Returns the edge list of a graph.
Method get_eid Returns the edge ID of an arbitrary edge between vertices v1 and v2
Method get_eids Returns the edge IDs of some edges between some vertices.
Method get_isomorphisms_vf2 Returns all isomorphisms between the graph and another one
Method get_k_shortest_paths Calculates the k shortest paths from/to a given node in a graph.
Method get_shortest_path Calculates the shortest path from a source vertex to a target vertex in a graph.
Method get_shortest_path_astar Calculates the shortest path from a source vertex to a target vertex in a graph using the A-Star algorithm and a heuristic function.
Method get_shortest_paths Calculates the shortest paths from/to a given node in a graph.
Method get_subisomorphisms_lad Returns all subisomorphisms between the graph and another one using the LAD algorithm.
Method get_subisomorphisms_vf2 Returns all subisomorphisms between the graph and another one
Method girth Returns the girth of the graph.
Method gomory_hu_tree Internal function, undocumented.
Method Growing_Random Generates a growing random graph.
Method harmonic_centrality Calculates the harmonic centralities of given vertices in a graph.
Method has_multiple Checks whether the graph has multiple edges.
Method Hexagonal_Lattice Generates a regular hexagonal lattice.
Method hub_score Calculates Kleinberg's hub score for the vertices of the graph
Method incident Returns the edges a given vertex is incident on.
Method independence_number Returns the independence number of the graph.
Method independent_vertex_sets Returns some or all independent vertex sets of the graph as a list of tuples.
Method induced_subgraph Returns a subgraph spanned by the given vertices.
Method is_acyclic Returns whether the graph is acyclic (i.e. contains no cycles).
Method is_bipartite Decides whether the graph is bipartite or not.
Method is_chordal Returns whether the graph is chordal or not.
Method is_connected Decides whether the graph is connected.
Method is_dag Checks whether the graph is a DAG (directed acyclic graph).
Method is_directed Checks whether the graph is directed.
Method is_loop Checks whether a specific set of edges contain loop edges
Method is_minimal_separator Decides whether the given vertex set is a minimal separator.
Method is_multiple Checks whether an edge is a multiple edge.
Method is_mutual Checks whether an edge has an opposite pair.
Method is_separator Decides whether the removal of the given vertices disconnects the graph.
Method is_simple Checks whether the graph is simple (no loop or multiple edges).
Method is_tree Checks whether the graph is a (directed or undirected) tree graph.
Method Isoclass Generates a graph with a given isomorphism class.
Method isoclass Returns the isomorphism class of the graph or its subgraph.
Method isomorphic Checks whether the graph is isomorphic to another graph.
Method isomorphic_bliss Checks whether the graph is isomorphic to another graph, using the BLISS isomorphism algorithm.
Method isomorphic_vf2 Checks whether the graph is isomorphic to another graph, using the VF2 isomorphism algorithm.
Method K_Regular Generates a k-regular random graph
Method Kautz Generates a Kautz graph with parameters (m, n)
Method knn Calculates the average degree of the neighbors for each vertex, and the same quantity as the function of vertex degree.
Method laplacian Returns the Laplacian matrix of a graph.
Method largest_cliques Returns the largest cliques of the graph as a list of tuples.
Method largest_independent_vertex_sets Returns the largest independent vertex sets of the graph as a list of tuples.
Method Lattice Generates a regular square lattice.
Method layout_bipartite Place the vertices of a bipartite graph in two layers.
Method layout_circle Places the vertices of the graph uniformly on a circle or a sphere.
Method layout_davidson_harel Places the vertices on a 2D plane according to the Davidson-Harel layout algorithm.
Method layout_drl Places the vertices on a 2D plane or in the 3D space ccording to the DrL layout algorithm.
Method layout_fruchterman_reingold Places the vertices on a 2D plane according to the Fruchterman-Reingold algorithm.
Method layout_graphopt This is a port of the graphopt layout algorithm by Michael Schmuhl. graphopt version 0.4.1 was rewritten in C and the support for layers was removed.
Method layout_grid Places the vertices of a graph in a 2D or 3D grid.
Method layout_kamada_kawai Places the vertices on a plane according to the Kamada-Kawai algorithm.
Method layout_lgl Places the vertices on a 2D plane according to the Large Graph Layout.
Method layout_mds Places the vertices in an Euclidean space with the given number of dimensions using multidimensional scaling.
Method layout_random Places the vertices of the graph randomly.
Method layout_reingold_tilford Places the vertices on a 2D plane according to the Reingold-Tilford layout algorithm.
Method layout_reingold_tilford_circular Circular Reingold-Tilford layout for trees.
Method layout_star Calculates a star-like layout for the graph.
Method layout_umap Uniform Manifold Approximation and Projection (UMAP).
Method LCF Generates a graph from LCF notation.
Method linegraph Returns the line graph of the graph.
Method list_triangles Lists the triangles of the graph
Method maxdegree Returns the maximum degree of a vertex set in the graph.
Method maxflow Returns the maximum flow between the source and target vertices.
Method maxflow_value Returns the value of the maximum flow between the source and target vertices.
Method maximal_cliques Returns the maximal cliques of the graph as a list of tuples.
Method maximal_independent_vertex_sets Returns the maximal independent vertex sets of the graph as a list of tuples.
Method maximum_cardinality_search Conducts a maximum cardinality search on the graph. The function computes a rank alpha for each vertex such that visiting vertices in decreasing rank order corresponds to always choosing the vertex with the most already visited neighbors as the next one to visit.
Method mincut Calculates the minimum cut between the source and target vertices or within the whole graph.
Method mincut_value Returns the minimum cut between the source and target vertices or within the whole graph.
Method minimum_cycle_basis Computes a minimum cycle basis of the graph
Method minimum_size_separators Returns a list containing all separator vertex sets of minimum size.
Method modularity Calculates the modularity of the graph with respect to some vertex types.
Method modularity_matrix Calculates the modularity matrix of the graph.
Method motifs_randesu Counts the number of motifs in the graph
Method motifs_randesu_estimate Counts the total number of motifs in the graph
Method motifs_randesu_no Counts the total number of motifs in the graph
Method neighborhood For each vertex specified by vertices, returns the vertices reachable from that vertex in at most order steps. If mindist is larger than zero, vertices that are reachable in less than mindist steps are excluded.
Method neighborhood_size For each vertex specified by vertices, returns the number of vertices reachable from that vertex in at most order steps. If mindist is larger than zero, vertices that are reachable in less than mindist...
Method neighbors Returns adjacent vertices to a given vertex.
Method permute_vertices Permutes the vertices of the graph according to the given permutation and returns the new graph.
Method personalized_pagerank Calculates the personalized PageRank values of a graph.
Method predecessors Returns the predecessors of a given vertex.
Method Preference Generates a graph based on vertex types and connection probabilities.
Method radius Calculates the radius of the graph.
Method random_walk Performs a random walk of a given length from a given node.
Method Read_DIMACS Reads a graph from a file conforming to the DIMACS minimum-cost flow file format.
Method Read_DL Reads an UCINET DL file and creates a graph based on it.
Method Read_Edgelist Reads an edge list from a file and creates a graph based on it.
Method Read_GML Reads a GML file and creates a graph based on it.
Method Read_GraphDB Reads a GraphDB format file and creates a graph based on it.
Method Read_GraphML Reads a GraphML format file and creates a graph based on it.
Method Read_Lgl Reads an .lgl file used by LGL.
Method Read_Ncol Reads an .ncol file used by LGL.
Method Read_Pajek Reads a file in the Pajek format and creates a graph based on it. Only Pajek network files (.net extension) are supported, not project files (.paj).
Method Realize_Degree_Sequence Generates a graph from a degree sequence.
Method Recent_Degree Generates a graph based on a stochastic model where the probability of an edge gaining a new node is proportional to the edges gained in a given time window.
Method reciprocity Reciprocity defines the proportion of mutual connections in a directed graph. It is most commonly defined as the probability that the opposite counterpart of a directed edge is also included in the graph...
Method reverse_edges Reverses the direction of some edges in the graph.
Method rewire Randomly rewires the graph while preserving the degree distribution.
Method rewire_edges Rewires the edges of a graph with constant probability.
Method Ring Generates a ring graph.
Method SBM Generates a graph based on a stochastic blockmodel.
Method similarity_dice Dice similarity coefficient of vertices.
Method similarity_inverse_log_weighted Inverse log-weighted similarity coefficient of vertices.
Method similarity_jaccard Jaccard similarity coefficient of vertices.
Method simplify Simplifies a graph by removing self-loops and/or multiple edges.
Method st_mincut Calculates the minimum cut between the source and target vertices in a graph.
Method Star Generates a star graph.
Method Static_Fitness Generates a non-growing graph with edge probabilities proportional to node fitnesses.
Method Static_Power_Law Generates a non-growing graph with prescribed power-law degree distributions.
Method strength Returns the strength (weighted degree) of some vertices from the graph
Method subcomponent Determines the indices of vertices which are in the same component as a given vertex.
Method subgraph_edges Returns a subgraph spanned by the given edges.
Method subisomorphic_lad Checks whether a subgraph of the graph is isomorphic to another graph.
Method subisomorphic_vf2 Checks whether a subgraph of the graph is isomorphic to another graph.
Method successors Returns the successors of a given vertex.
Method to_directed Converts an undirected graph to directed.
Method to_prufer Converts a tree graph into a Prufer sequence.
Method to_undirected Converts a directed graph to undirected.
Method topological_sorting Calculates a possible topological sorting of the graph.
Method transitivity_local_undirected Calculates the local transitivity (clustering coefficient) of the given vertices in the graph.
Method transitivity_undirected Calculates the global transitivity (clustering coefficient) of the graph.
Method Tree Generates a tree in which almost all vertices have the same number of children.
Method Tree_Game Generates a random tree by sampling uniformly from the set of labelled trees with a given number of nodes.
Method Triangular_Lattice Generates a regular triangular lattice.
Method unfold_tree Unfolds the graph using a BFS to a tree by duplicating vertices as necessary.
Method vcount Counts the number of vertices.
Method vertex_attributes No summary
Method vertex_coloring_greedy Calculates a greedy vertex coloring for the graph based on some heuristics.
Method vertex_connectivity Calculates the vertex connectivity of the graph or between some vertices.
Method Watts_Strogatz This function generates networks with the small-world property based on a variant of the Watts-Strogatz model. The network is obtained by first creating a periodic undirected lattice, then rewiring both endpoints of each edge with probability ...
Method write_dimacs Writes the graph in DIMACS format to the given file.
Method write_dot Writes the graph in DOT format to the given file.
Method write_edgelist Writes the edge list of a graph to a file.
Method write_gml Writes the graph in GML format to the given file.
Method write_graphml Writes the graph to a GraphML file.
Method write_leda Writes the graph to a file in LEDA native format.
Method write_lgl Writes the edge list of a graph to a file in .lgl format.
Method write_ncol Writes the edge list of a graph to a file in .ncol format.
Method write_pajek Writes the graph in Pajek format to the given file.
Method __graph_as_capsule Returns the igraph graph encapsulated by the Python object as a PyCapsule
Method __invalidate_cache Invalidates the internal cache of the low-level C graph object that the Python object wraps. This function should not be used directly by igraph users, but it may be useful for benchmarking or debugging purposes.
Method __register_destructor Registers a destructor to be called when the object is freed by Python. This function should not be used directly by igraph users.
Method _Biadjacency Internal function, undocumented.
Method _Bipartite Internal function, undocumented.
Method _Full_Bipartite Internal function, undocumented.
Method _get_all_simple_paths Internal function, undocumented.
Method _GRG Internal function, undocumented.
Method _is_matching Internal function, undocumented.
Method _is_maximal_matching Internal function, undocumented.
Method _layout_sugiyama Internal function, undocumented.
Method _maximum_bipartite_matching Internal function, undocumented.
Method _Random_Bipartite Internal function, undocumented.
Method _raw_pointer Returns the memory address of the igraph graph encapsulated by the Python object as an ordinary Python integer.
Method _spanning_tree Internal function, undocumented.
Method _Weighted_Adjacency Generates a graph from its adjacency matrix.
@classmethod
def Incidence(cls, *args, **kwds): (source)

Deprecated alias to Graph.Biadjacency().

def __bool__(self): (source)

Returns True if the graph has at least one vertex, False otherwise.

def __coerce__(self, other): (source)

Coercion rules.

This method is needed to allow the graph to react to additions with lists, tuples, integers, strings, vertices, edges and so on.

def __init__(self, *args, **kwds): (source)

__init__(n=0, edges=None, directed=False, graph_attrs=None, vertex_attrs=None, edge_attrs=None)

Constructs a graph from scratch.

Parameters
*argsUndocumented
nthe number of vertices. Can be omitted, the default is zero. Note that if the edge list contains vertices with indexes larger than or equal to n, then the number of vertices will be adjusted accordingly.
edgesthe edge list where every list item is a pair of integers. If any of the integers is larger than n − 1, the number of vertices is adjusted accordingly. None means no edges.
directedwhether the graph should be directed
graph_attrsthe attributes of the graph as a dictionary.
vertex_attrsthe attributes of the vertices as a dictionary. The keys of the dictionary must be the names of the attributes; the values must be iterables with exactly n items where n is the number of vertices.
edge_attrsthe attributes of the edges as a dictionary. The keys of the dictionary must be the names of the attributes; the values must be iterables with exactly m items where m is the number of edges.
def __reduce__(self): (source)

Support for pickling.

def __str__(self): (source)

Returns a string representation of the graph.

Behind the scenes, this method constructs a GraphSummary instance and invokes its __str__ method with a verbosity of 1 and attribute printing turned off.

See the documentation of GraphSummary for more details about the output.

def dfs(self, vid, mode=OUT): (source)

Conducts a depth first search (DFS) on the graph.

Parameters
vidthe root vertex ID
modeeither "in" or "out" or "all", ignored for undirected graphs.
Returns

a tuple with the following items:

  • The vertex IDs visited (in order)
  • The parent of every vertex in the DFS
def dyad_census(self, *args, **kwds): (source)

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. A Method for Detecting Structure in Sociometric Data. American Journal of Sociology, 70, 492-513, 1970.

Returns
a DyadCensus object.
def get_all_simple_paths(self, v, to=None, cutoff=-1, mode='out'): (source)

Calculates all the simple paths from a given node to some other nodes (or all of them) in a graph.

A path is simple if its vertices are unique, i.e. no vertex is visited more than once.

Note that potentially there are exponentially many paths between two vertices of a graph, especially if your graph is lattice-like. In this case, you may run out of memory when using this function.

Parameters
vthe source for the calculated paths
toa vertex selector describing the destination for the calculated paths. This can be a single vertex ID, a list of vertex IDs, a single vertex name, a list of vertex names or a VertexSeq object. None means all the vertices.
cutoffmaximum length of path that is considered. If negative, paths of all lengths are considered.
modethe directionality of the paths. "in" means to calculate incoming paths, "out" means to calculate outgoing paths, "all" means to calculate both ones.
Returns
all of the simple paths from the given node to every other reachable node in the graph in a list. Note that in case of mode="in", the vertices in a path are returned in reversed order!
def get_incidence(self, *args, **kwds): (source)

Deprecated alias to Graph.get_biadjacency().

def is_named(self): (source)

Returns whether the graph is named.

A graph is named if and only if it has a "name" vertex attribute.

def is_weighted(self): (source)

Returns whether the graph is weighted.

A graph is weighted if and only if it has a "weight" edge attribute.

def path_length_hist(self, directed=True): (source)

Returns the path length histogram of the graph

Parameters
directedwhether to consider directed paths. Ignored for undirected graphs.
Returns
a Histogram object. The object will also have an unconnected attribute that stores the number of unconnected vertex pairs (where the second vertex can not be reached from the first one). The latter one will be of type long (and not a simple integer), since this can be very large.
def spanning_tree(self, weights=None, return_tree=True): (source)

Calculates a minimum spanning tree for a graph.

Reference: Prim, R.C. Shortest connection networks and some generalizations. Bell System Technical Journal 36:1389-1401, 1957.

Parameters
weightsa vector containing weights for every edge in the graph. None means that the graph is unweighted.
return_treewhether to return the minimum spanning tree (when return_tree is True) or to return the IDs of the edges in the minimum spanning tree instead (when return_tree is False). The default is True for historical reasons as this argument was introduced in igraph 0.6.
Returns
the spanning tree as a Graph object if return_tree is True or the IDs of the edges that constitute the spanning tree if return_tree is False.
def summary(self, verbosity=0, width=None, *args, **kwds): (source)

Returns the summary of the graph.

The output of this method is similar to the output of the __str__ method. If verbosity is zero, only the header line is returned (see __str__ for more details), otherwise the header line and the edge list is printed.

Behind the scenes, this method constructs a GraphSummary object and invokes its __str__ method.

Parameters
verbosityif zero, only the header line is returned (see __str__ for more details), otherwise the header line and the full edge list is printed.
widththe number of characters to use in one line. If None, no limit will be enforced on the line lengths.
*argsUndocumented
**kwdsUndocumented
Returns
the summary of the graph.
def transitivity_avglocal_undirected(self, mode='nan', weights=None): (source)

Calculates the average of the vertex transitivities of the graph.

In the unweighted case, the transitivity measures the probability that two neighbors of a vertex are connected. In case of the average local transitivity, this probability is calculated for each vertex and then the average is taken. Vertices with less than two neighbors require special treatment, they will either be left out from the calculation or they will be considered as having zero transitivity, depending on the mode parameter. The calculation is slightly more involved for weighted graphs; in this case, weights are taken into account according to the formula of Barrat et al (see the references).

Note that this measure is different from the global transitivity measure (see transitivity_undirected()) as it simply takes the average local transitivity across the whole network.

References

  • Watts DJ and Strogatz S: Collective dynamics of small-world networks. Nature 393(6884):440-442, 1998.
  • Barrat A, Barthelemy M, Pastor-Satorras R and Vespignani A: The architecture of complex weighted networks. PNAS 101, 3747 (2004). http://arxiv.org/abs/cond-mat/0311416.
Parameters
modedefines how to treat vertices with degree less than two. If TRANSITIVITY_ZERO or "zero", these vertices will have zero transitivity. If TRANSITIVITY_NAN or "nan", these vertices will be excluded from the average.
weightsedge weights to be used. Can be a sequence or iterable or even an edge attribute name.
See Also
transitivity_undirected(), transitivity_local_undirected()
def triad_census(self, *args, **kwds): (source)

Calculates the triad census of the graph.

Reference: Davis, J.A. and Leinhardt, S. The Structure of Positive Interpersonal Relations in Small Groups. In: J. Berger (Ed.), Sociological Theories in Progress, Volume 2, 218-251. Boston: Houghton Mifflin (1972).

Returns
a TriadCensus object.

Undocumented

Value
classmethod(_construct_random_geometric_graph)

Undocumented

Undocumented

__hash__ = (source)

Undocumented

__iadd__ = (source)

Undocumented

__isub__ = (source)

Undocumented

__iter__ = (source)

Undocumented

Undocumented

Undocumented

Undocumented

Biadjacency = (source)

Undocumented

Bipartite = (source)

Undocumented

DataFrame = (source)

Undocumented

DictDict = (source)

Undocumented

DictList = (source)

Undocumented

disjoint_union = (source)

Undocumented

Undocumented

from_graph_tool = (source)

Undocumented

from_networkx = (source)

Undocumented

Full_Bipartite = (source)

Undocumented

intersection = (source)

Undocumented

ListDict = (source)

Undocumented

Random_Bipartite = (source)

Undocumented

Undocumented

Read_Adjacency = (source)

Undocumented

Read_GraphMLz = (source)

Undocumented

Read_Pickle = (source)

Undocumented

Read_Picklez = (source)

Undocumented

TupleList = (source)

Undocumented

Undocumented

Weighted_Adjacency = (source)

Undocumented

@property
es = (source)

The edge sequence of the graph

@property
vs = (source)

The vertex sequence of the graph

@classmethod
def _reconstruct(cls, attrs, *args, **kwds): (source)

Reconstructs a Graph object from Python's pickled format.

This method is for internal use only, it should not be called directly.

@property
_as_parameter_ = (source)

Undocumented