Graph constructors
igraph_ctypes.constructors module
create_empty_graph(n=0, directed=False)
Creates an empty graph with the given number of vertices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
the number of vertices |
0
|
directed
|
bool
|
whether the graph is directed |
False
|
Returns:
| Type | Description |
|---|---|
Graph
|
the newly created graph |
create_famous_graph(name)
Creates one of the "famous" graphs embedded into igraph by name.
See the documentation of the igraph_famous() function in igraph's C core
for a list of names accepted by this function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
the name of the graph to construct |
required |
Returns:
| Type | Description |
|---|---|
Graph
|
the constructed graph |
create_full_graph(n, directed=False, loops=False)
Creates a full graph with the given number of vertices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
the number of vertices |
required |
directed
|
bool
|
whether the graph is directed |
False
|
loops
|
bool
|
whether each vertex should also have a loop edge |
False
|
Returns:
| Type | Description |
|---|---|
Graph
|
the newly created graph |
create_geometric_random_graph(n, radius, torus=False)
Creates a geometric random graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
the number of vertices in the graph |
required |
radius
|
float
|
connection distance; two vertices will be connected if they are closer to each other than this threshold |
required |
create_graph_from_edge_list(edges, n=0, directed=True)
Creates a graph from the given edge list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
Iterable[int]
|
the list of edges in the graph |
required |
n
|
int
|
the number of vertices in the graph if it cannot be inferred from the maximum edge ID in the edge list |
0
|
Returns:
| Type | Description |
|---|---|
Graph
|
the newly created graph |
create_square_lattice(dimvector, nei=1, directed=False, mutual=False, periodic=False)
Creates a square lattice graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimvector
|
Iterable[int]
|
number of vertices along each dimension of the lattice |
required |
directed
|
bool
|
whether the generated lattice should be directed |
False
|
mutual
|
bool
|
whether the vertices should be connected in both directions if the lattice is directed |
False
|
periodic
|
Union[bool, Iterable[bool]]
|
whether the lattice should be periodic along each dimension.
|
False
|