Skip to content

Commit 6694b86

Browse files
committed
refactor: even less boilerplate
1 parent b085992 commit 6694b86

File tree

3 files changed

+19
-36
lines changed

3 files changed

+19
-36
lines changed

doc/fragments/igraph_create.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Creates a graph from the given edge list.
2+
3+
Parameters:
4+
edges: the list of edges in the graph
5+
n: the number of vertices in the graph if it cannot be inferred from
6+
the maximum edge ID in the edge list
7+
8+
Returns:
9+
the newly created graph

doc/fragments/igraph_empty.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ Creates an empty graph with the given number of vertices.
33
Parameters:
44
n: the number of vertices
55
directed: whether the graph is directed
6+
7+
Returns:
8+
the newly created graph

src/igraph_ctypes/constructors.py

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
from typing import Iterable, Union
22

33
from .graph import Graph
4-
from ._internal.functions import create, empty, famous, grg_game, square_lattice
4+
from ._internal.functions import (
5+
create as create_graph_from_edge_list,
6+
empty as create_empty_graph,
7+
famous as create_famous_graph,
8+
grg_game,
9+
square_lattice,
10+
)
511

612
__all__ = (
713
"create_empty_graph",
@@ -12,41 +18,6 @@
1218
)
1319

1420

15-
def create_empty_graph(n: int, directed: bool = False) -> Graph:
16-
"""Creates an empty graph with the given number of vertices.
17-
18-
Parameters:
19-
n: the number of vertices
20-
directed: whether the graph is directed
21-
"""
22-
return empty(n, directed)
23-
24-
25-
def create_famous_graph(name: str) -> Graph:
26-
"""Creates one of the "famous" graphs embedded into igraph by name.
27-
28-
See the documentation of the ``igraph_famous()`` function in igraph's C core
29-
for a list of names accepted by this function.
30-
31-
Parameters:
32-
name: the name of the graph to construct
33-
"""
34-
return famous(name)
35-
36-
37-
def create_graph_from_edge_list(
38-
edges: Iterable[int], n: int = 0, directed: bool = False
39-
) -> Graph:
40-
"""Creates a graph from the given edge list.
41-
42-
Parameters:
43-
edges: the list of edges in the graph
44-
n: the number of vertices in the graph if it cannot be inferred from
45-
the maximum edge ID in the edge list
46-
"""
47-
return create(edges, n, directed)
48-
49-
5021
def create_square_lattice(
5122
dimvector: Iterable[int],
5223
nei: int = 1,

0 commit comments

Comments
 (0)