Skip to content

Commit c0515a4

Browse files
petercorkeclaude
andcommitted
refactor: Graph and Vertex are the names of the common base classes
BaseGraph and BaseVertex become Graph and Vertex. Both names were introduced after 0.6.5 and never released, so there are no aliases. This is the mechanical half of making Vertex the one vertex class: the names say what the classes are, rather than that they are bases of something. Mechanical: every change is a whole-word replacement of BaseGraph or BaseVertex, and the full suite, mypy and pyflakes are unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 4f72b64 commit c0515a4

18 files changed

Lines changed: 364 additions & 364 deletions

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Graphs belong to the class `UGraph` or `DGraph` for undirected or directed graph
9696
- `g.incidence()` incidence matrix
9797

9898
### Properties and methods of a vertex
99-
Vertices belong to the class `UVertex` (for undirected graphs) or `DVertex` (for directed graphs), which are each subclasses of `BaseVertex`.
99+
Vertices belong to the class `UVertex` (for undirected graphs) or `DVertex` (for directed graphs), which are each subclasses of `Vertex`.
100100

101101
- `v.coord` the coordinate vector for embedded graph (optional)
102102
- `v.name` the name of the vertex (optional)

‎docs/source/analysis.rst‎

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,55 @@ Graph
1313
.. autosummary::
1414
:nosignatures:
1515

16-
~pgraph.PGraph.BaseGraph.n
17-
~pgraph.PGraph.BaseGraph.ne
18-
~pgraph.PGraph.BaseGraph.nc
19-
~pgraph.PGraph.BaseGraph.edges
20-
~pgraph.PGraph.BaseGraph.average_degree
21-
~pgraph.PGraph.BaseGraph.iscyclic
22-
~pgraph.PGraph.BaseGraph.connectivity
23-
~pgraph.PGraph.BaseGraph.component
24-
~pgraph.PGraph.BaseGraph.samecomponent
25-
~pgraph.PGraph.BaseGraph.closest
16+
~pgraph.PGraph.Graph.n
17+
~pgraph.PGraph.Graph.ne
18+
~pgraph.PGraph.Graph.nc
19+
~pgraph.PGraph.Graph.edges
20+
~pgraph.PGraph.Graph.average_degree
21+
~pgraph.PGraph.Graph.iscyclic
22+
~pgraph.PGraph.Graph.connectivity
23+
~pgraph.PGraph.Graph.component
24+
~pgraph.PGraph.Graph.samecomponent
25+
~pgraph.PGraph.Graph.closest
2626

2727
Vertex
2828
------
2929

3030
.. autosummary::
3131
:nosignatures:
3232

33-
~pgraph.PGraph.BaseVertex.edges
34-
~pgraph.PGraph.BaseVertex.adjacent
35-
~pgraph.PGraph.BaseVertex.isadjacent
36-
~pgraph.PGraph.BaseVertex.incidences
37-
~pgraph.PGraph.BaseVertex.degree
38-
~pgraph.PGraph.BaseVertex.heuristic_distance
39-
~pgraph.PGraph.BaseVertex.distance
40-
~pgraph.PGraph.BaseVertex.x
41-
~pgraph.PGraph.BaseVertex.y
42-
~pgraph.PGraph.BaseVertex.z
33+
~pgraph.PGraph.Vertex.edges
34+
~pgraph.PGraph.Vertex.adjacent
35+
~pgraph.PGraph.Vertex.isadjacent
36+
~pgraph.PGraph.Vertex.incidences
37+
~pgraph.PGraph.Vertex.degree
38+
~pgraph.PGraph.Vertex.heuristic_distance
39+
~pgraph.PGraph.Vertex.distance
40+
~pgraph.PGraph.Vertex.x
41+
~pgraph.PGraph.Vertex.y
42+
~pgraph.PGraph.Vertex.z
4343

4444
Details
4545
-------
4646

47-
.. autoproperty:: pgraph.PGraph.BaseGraph.n
48-
.. autoproperty:: pgraph.PGraph.BaseGraph.ne
49-
.. autoproperty:: pgraph.PGraph.BaseGraph.nc
50-
.. automethod:: pgraph.PGraph.BaseGraph.edges
51-
.. automethod:: pgraph.PGraph.BaseGraph.average_degree
52-
.. automethod:: pgraph.PGraph.BaseGraph.iscyclic
53-
.. automethod:: pgraph.PGraph.BaseGraph.connectivity
54-
.. automethod:: pgraph.PGraph.BaseGraph.component
55-
.. automethod:: pgraph.PGraph.BaseGraph.samecomponent
56-
.. automethod:: pgraph.PGraph.BaseGraph.closest
47+
.. autoproperty:: pgraph.PGraph.Graph.n
48+
.. autoproperty:: pgraph.PGraph.Graph.ne
49+
.. autoproperty:: pgraph.PGraph.Graph.nc
50+
.. automethod:: pgraph.PGraph.Graph.edges
51+
.. automethod:: pgraph.PGraph.Graph.average_degree
52+
.. automethod:: pgraph.PGraph.Graph.iscyclic
53+
.. automethod:: pgraph.PGraph.Graph.connectivity
54+
.. automethod:: pgraph.PGraph.Graph.component
55+
.. automethod:: pgraph.PGraph.Graph.samecomponent
56+
.. automethod:: pgraph.PGraph.Graph.closest
5757

58-
.. automethod:: pgraph.PGraph.BaseVertex.edges
59-
.. automethod:: pgraph.PGraph.BaseVertex.adjacent
60-
.. automethod:: pgraph.PGraph.BaseVertex.isadjacent
61-
.. automethod:: pgraph.PGraph.BaseVertex.incidences
62-
.. autoproperty:: pgraph.PGraph.BaseVertex.degree
63-
.. automethod:: pgraph.PGraph.BaseVertex.heuristic_distance
64-
.. automethod:: pgraph.PGraph.BaseVertex.distance
65-
.. autoproperty:: pgraph.PGraph.BaseVertex.x
66-
.. autoproperty:: pgraph.PGraph.BaseVertex.y
67-
.. autoproperty:: pgraph.PGraph.BaseVertex.z
58+
.. automethod:: pgraph.PGraph.Vertex.edges
59+
.. automethod:: pgraph.PGraph.Vertex.adjacent
60+
.. automethod:: pgraph.PGraph.Vertex.isadjacent
61+
.. automethod:: pgraph.PGraph.Vertex.incidences
62+
.. autoproperty:: pgraph.PGraph.Vertex.degree
63+
.. automethod:: pgraph.PGraph.Vertex.heuristic_distance
64+
.. automethod:: pgraph.PGraph.Vertex.distance
65+
.. autoproperty:: pgraph.PGraph.Vertex.x
66+
.. autoproperty:: pgraph.PGraph.Vertex.y
67+
.. autoproperty:: pgraph.PGraph.Vertex.z

‎docs/source/common.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ Common methods
44
The package supports both directed (prefix ``D``) and undirected graphs (prefix ``U``), and the classes for these
55
share a common interface.
66

7-
The graph classes represent a single graph, either directed or undirected, and they share :class:`BaseGraph`:
7+
The graph classes represent a single graph, either directed or undirected, and they share :class:`Graph`:
88

99
.. inheritance-diagram:: pgraph.PGraph.UGraph pgraph.PGraph.DGraph
1010
:parts: 1
1111
:private-bases:
12-
:top-classes: pgraph.PGraph.BaseGraph
12+
:top-classes: pgraph.PGraph.Graph
1313

1414
The vertices in a directed graph (``DGraph``) inherit from :class:`DVertex` and the
1515
vertices in an undirected graph (``UGraph``) inherit from :class:`UVertex`.
@@ -19,7 +19,7 @@ vertices in an undirected graph (``UGraph``) inherit from :class:`UVertex`.
1919

2020
The vertex classes share
2121
almost their entire interface, defined once on their common base classes
22-
(:class:`BaseGraph`, :class:`BaseVertex`). This section documents that
22+
(:class:`Graph`, :class:`Vertex`). This section documents that
2323
shared interface by task rather than by class; see :doc:`construction` for
2424
the :class:`DGraph` and :class:`UGraph` classes and :doc:`edges_vertices` for
2525
what's specific to directed vs. undirected vertices.

‎docs/source/construction.rst‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ standalone, independent of a graph.
1212

1313
~pgraph.PGraph.DGraph
1414
~pgraph.PGraph.UGraph
15-
~pgraph.PGraph.BaseGraph.Dict
16-
~pgraph.PGraph.BaseGraph.Adjacency
15+
~pgraph.PGraph.Graph.Dict
16+
~pgraph.PGraph.Graph.Adjacency
1717

1818

1919
.. autoclass:: pgraph.PGraph.DGraph
@@ -22,17 +22,17 @@ standalone, independent of a graph.
2222
.. autoclass:: pgraph.PGraph.UGraph
2323
:show-inheritance:
2424

25-
.. autoclass:: pgraph.PGraph.BaseGraph.Adjacency
25+
.. autoclass:: pgraph.PGraph.Graph.Adjacency
2626
:show-inheritance:
2727

28-
.. autoclass:: pgraph.PGraph.BaseGraph.Dict
28+
.. autoclass:: pgraph.PGraph.Graph.Dict
2929
:show-inheritance:
3030

3131

3232
Inherited methods for all graph types
3333
--------------------------------------
3434

35-
.. autoclass:: pgraph.PGraph.BaseGraph
35+
.. autoclass:: pgraph.PGraph.Graph
3636
:members: copy, vertex_copy, metric, heuristic, show, vertex_class, edge_class
3737
:special-members: __init__, __str__, __repr__, __getitem__, __iter__, __contains__
3838

‎docs/source/export.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ it.
1313
.. autosummary::
1414
:nosignatures:
1515

16-
~pgraph.PGraph.BaseGraph.export
17-
~pgraph.PGraph.BaseGraph.dotfile
16+
~pgraph.PGraph.Graph.export
17+
~pgraph.PGraph.Graph.dotfile
1818

1919
Details
2020
-------
2121

22-
.. automethod:: pgraph.PGraph.BaseGraph.export
23-
.. automethod:: pgraph.PGraph.BaseGraph.dotfile
22+
.. automethod:: pgraph.PGraph.Graph.export
23+
.. automethod:: pgraph.PGraph.Graph.dotfile

‎docs/source/modification.rst‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,30 @@ Graph
1313
.. autosummary::
1414
:nosignatures:
1515

16-
~pgraph.PGraph.BaseGraph.add_vertex
17-
~pgraph.PGraph.BaseGraph.add_edge
18-
~pgraph.PGraph.BaseGraph.remove_edge
19-
~pgraph.PGraph.BaseGraph.remove_vertex
16+
~pgraph.PGraph.Graph.add_vertex
17+
~pgraph.PGraph.Graph.add_edge
18+
~pgraph.PGraph.Graph.remove_edge
19+
~pgraph.PGraph.Graph.remove_vertex
2020

2121
Vertex
2222
------
2323

2424
.. autosummary::
2525
:nosignatures:
2626

27-
~pgraph.PGraph.BaseVertex.connect
28-
~pgraph.PGraph.BaseVertex.edgeto
29-
~pgraph.PGraph.BaseVertex.remove
27+
~pgraph.PGraph.Vertex.connect
28+
~pgraph.PGraph.Vertex.edgeto
29+
~pgraph.PGraph.Vertex.remove
3030

3131
Details
3232
-------
3333

34-
.. automethod:: pgraph.PGraph.BaseGraph.add_vertex
35-
.. automethod:: pgraph.PGraph.BaseGraph.add_edge
36-
.. automethod:: pgraph.PGraph.BaseGraph.remove_edge
37-
.. automethod:: pgraph.PGraph.BaseGraph.remove_vertex
38-
.. automethod:: pgraph.PGraph.BaseGraph.remove
34+
.. automethod:: pgraph.PGraph.Graph.add_vertex
35+
.. automethod:: pgraph.PGraph.Graph.add_edge
36+
.. automethod:: pgraph.PGraph.Graph.remove_edge
37+
.. automethod:: pgraph.PGraph.Graph.remove_vertex
38+
.. automethod:: pgraph.PGraph.Graph.remove
3939

40-
.. automethod:: pgraph.PGraph.BaseVertex.connect
41-
.. automethod:: pgraph.PGraph.BaseVertex.edgeto
42-
.. automethod:: pgraph.PGraph.BaseVertex.remove
40+
.. automethod:: pgraph.PGraph.Vertex.connect
41+
.. automethod:: pgraph.PGraph.Vertex.edgeto
42+
.. automethod:: pgraph.PGraph.Vertex.remove

‎docs/source/planning.rst‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ These methods find optimal paths from a start vertex to a goal vertex.
66
.. autosummary::
77
:nosignatures:
88

9-
~pgraph.PGraph.BaseGraph.path_BFS
10-
~pgraph.PGraph.BaseGraph.path_UCS
11-
~pgraph.PGraph.BaseGraph.path_Astar
9+
~pgraph.PGraph.Graph.path_BFS
10+
~pgraph.PGraph.Graph.path_UCS
11+
~pgraph.PGraph.Graph.path_Astar
1212

1313
Details
1414
-------
1515

16-
.. automethod:: pgraph.PGraph.BaseGraph.path_BFS
17-
.. automethod:: pgraph.PGraph.BaseGraph.path_UCS
18-
.. automethod:: pgraph.PGraph.BaseGraph.path_Astar
16+
.. automethod:: pgraph.PGraph.Graph.path_BFS
17+
.. automethod:: pgraph.PGraph.Graph.path_UCS
18+
.. automethod:: pgraph.PGraph.Graph.path_Astar

‎docs/source/policy.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Object lifecycle and graph-membership policy
22
=============================================
33

4-
``BaseVertex``, ``UVertex``, ``DVertex`` and ``Edge`` can all be constructed
4+
``Vertex``, ``UVertex``, ``DVertex`` and ``Edge`` can all be constructed
55
directly, independent of any graph. This is deliberate -- it is not an
66
oversight and not a "factory-only" design -- but it means the rules for what
77
those objects can and can't do *before* they belong to a graph need to be
@@ -26,7 +26,7 @@ Adding a vertex to a graph
2626
:meth:`UGraph.add_vertex` and :meth:`DGraph.add_vertex` each only accept
2727
their own matching vertex subclass -- a ``UVertex`` (or coordinate data, from
2828
which one is built) for :class:`UGraph`, a ``DVertex`` for :class:`DGraph`.
29-
Passing the wrong kind of vertex -- a plain ``BaseVertex``, or the other
29+
Passing the wrong kind of vertex -- a plain ``Vertex``, or the other
3030
graph's subclass -- raises ``TypeError`` rather than being silently accepted
3131
or converted.
3232

@@ -79,7 +79,7 @@ Summary
7979
* - Operation
8080
- Requires graph membership?
8181
- Failure mode
82-
* - ``UVertex()`` / ``DVertex()`` / ``BaseVertex()``
82+
* - ``UVertex()`` / ``DVertex()`` / ``Vertex()``
8383
- No
8484
- --
8585
* - ``Edge(v1, v2)``

‎docs/source/representations.rst‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ These methods convert the graph to a number of different matrix representations.
77
.. autosummary::
88
:nosignatures:
99

10-
~pgraph.PGraph.BaseGraph.distance
11-
~pgraph.PGraph.BaseGraph.adjacency
12-
~pgraph.PGraph.BaseGraph.degree
13-
~pgraph.PGraph.BaseGraph.incidence
14-
~pgraph.PGraph.BaseGraph.laplacian
10+
~pgraph.PGraph.Graph.distance
11+
~pgraph.PGraph.Graph.adjacency
12+
~pgraph.PGraph.Graph.degree
13+
~pgraph.PGraph.Graph.incidence
14+
~pgraph.PGraph.Graph.laplacian
1515

1616
Details
1717
-------
1818

19-
.. automethod:: pgraph.PGraph.BaseGraph.distance
20-
.. automethod:: pgraph.PGraph.BaseGraph.adjacency
21-
.. automethod:: pgraph.PGraph.BaseGraph.degree
22-
.. automethod:: pgraph.PGraph.BaseGraph.incidence
23-
.. automethod:: pgraph.PGraph.BaseGraph.laplacian
19+
.. automethod:: pgraph.PGraph.Graph.distance
20+
.. automethod:: pgraph.PGraph.Graph.adjacency
21+
.. automethod:: pgraph.PGraph.Graph.degree
22+
.. automethod:: pgraph.PGraph.Graph.incidence
23+
.. automethod:: pgraph.PGraph.Graph.laplacian
2424

2525

‎docs/source/visualization.rst‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ file) rather than displaying it.
88
.. autosummary::
99
:nosignatures:
1010

11-
~pgraph.PGraph.BaseGraph.plot
12-
~pgraph.PGraph.BaseGraph.showgraph
13-
~pgraph.PGraph.BaseGraph.highlight_path
14-
~pgraph.PGraph.BaseGraph.highlight_edge
15-
~pgraph.PGraph.BaseGraph.highlight_vertex
11+
~pgraph.PGraph.Graph.plot
12+
~pgraph.PGraph.Graph.showgraph
13+
~pgraph.PGraph.Graph.highlight_path
14+
~pgraph.PGraph.Graph.highlight_edge
15+
~pgraph.PGraph.Graph.highlight_vertex
1616

1717
Details
1818
-------
1919

20-
.. automethod:: pgraph.PGraph.BaseGraph.plot
21-
.. automethod:: pgraph.PGraph.BaseGraph.showgraph
22-
.. automethod:: pgraph.PGraph.BaseGraph.highlight_path
23-
.. automethod:: pgraph.PGraph.BaseGraph.highlight_edge
24-
.. automethod:: pgraph.PGraph.BaseGraph.highlight_vertex
20+
.. automethod:: pgraph.PGraph.Graph.plot
21+
.. automethod:: pgraph.PGraph.Graph.showgraph
22+
.. automethod:: pgraph.PGraph.Graph.highlight_path
23+
.. automethod:: pgraph.PGraph.Graph.highlight_edge
24+
.. automethod:: pgraph.PGraph.Graph.highlight_vertex

0 commit comments

Comments
 (0)