1616from spatialmath .base .graphics import axes_logic
1717
1818
19- class _BaseGraph (ABC ):
19+ class BaseGraph (ABC ):
2020
2121 #: concrete vertex type for this graph kind, provided by :class:`UGraph`
2222 #: and :class:`DGraph` -- lets :meth:`add_vertex` and :meth:`vertex_copy`
@@ -140,7 +140,7 @@ def __repr__(self) -> str:
140140 return str (self )
141141
142142 @classmethod
143- def Dict (cls , d : dict , reverse : bool = False , ** kwargs : Any ) -> _BaseGraph :
143+ def Dict (cls , d : dict , reverse : bool = False , ** kwargs : Any ) -> BaseGraph :
144144 """
145145 Create graph from parent/child dictionary
146146
@@ -150,7 +150,7 @@ def Dict(cls, d: dict, reverse: bool = False, **kwargs: Any) -> _BaseGraph:
150150 :param kwargs: optional arguments passed to the graph constructor, for
151151 example ``vertex_class`` or ``edge_class``
152152 :raises TypeError: ``vertex_class`` or ``edge_class`` is not a
153- suitable class, see :meth:`_BaseGraph .__init__`
153+ suitable class, see :meth:`BaseGraph .__init__`
154154 :return: graph
155155 :rtype: UGraph or DGraph
156156
@@ -207,7 +207,7 @@ def Adjacency(
207207 coords : NDArray | None = None ,
208208 names : list [str ] | None = None ,
209209 ** kwargs : Any ,
210- ) -> _BaseGraph :
210+ ) -> BaseGraph :
211211 """
212212 Create graph from adjacency matrix
213213
@@ -222,7 +222,7 @@ def Adjacency(
222222 :raises ValueError: ``A`` is not square, or the length of ``names`` or
223223 the number of rows of ``coords`` does not match ``A``
224224 :raises TypeError: ``vertex_class`` or ``edge_class`` is not a
225- suitable class, see :meth:`_BaseGraph .__init__`
225+ suitable class, see :meth:`BaseGraph .__init__`
226226 :return: graph
227227 :rtype: UGraph or DGraph
228228
@@ -306,12 +306,12 @@ def edge_class(self) -> type[Edge]:
306306 """
307307 return self ._edge_class
308308
309- def copy (self ) -> _BaseGraph :
309+ def copy (self ) -> BaseGraph :
310310 """
311311 Deepcopy of graph
312312
313313 :return: deep copy
314- :rtype: _BaseGraph
314+ :rtype: BaseGraph
315315
316316 .. runblock:: pycon
317317
@@ -370,7 +370,7 @@ def add_vertex(
370370 >>> print(v2.name)
371371
372372 If the graph was constructed with a required ``dim`` (see
373- :meth:`_BaseGraph .__init__`), every embedded vertex must have a
373+ :meth:`BaseGraph .__init__`), every embedded vertex must have a
374374 coordinate of exactly that length -- adding one of the wrong length
375375 raises ``ValueError``:
376376
@@ -2478,18 +2478,18 @@ def path_Astar(
24782478# -------------------------------------------------------------------------- #
24792479
24802480
2481- class UGraph (_BaseGraph ):
2481+ class UGraph (BaseGraph ):
24822482 """
24832483 Class for undirected graphs
24842484
24852485 Vertices are :class:`UVertex` objects, or instances of the subclass given
24862486 as ``vertex_class``. Edges are :class:`Edge` objects, or instances of the
2487- subclass given as ``edge_class``; see :class:`_BaseGraph ` for the
2487+ subclass given as ``edge_class``; see :class:`BaseGraph ` for the
24882488 constructor arguments and the exceptions they raise.
24892489
24902490 .. inheritance-diagram:: UGraph
24912491
2492- :seealso: :class:`_BaseGraph ` :class:`DGraph`
2492+ :seealso: :class:`BaseGraph ` :class:`DGraph`
24932493 """
24942494
24952495 def _graphcolor (self ) -> None :
@@ -2537,18 +2537,18 @@ def _graphcolor(self) -> None:
25372537 self ._ncomponents = 0 if lastlabel is None else lastlabel + 1
25382538
25392539
2540- class DGraph (_BaseGraph ):
2540+ class DGraph (BaseGraph ):
25412541 """
25422542 Class for directed graphs
25432543
25442544 Vertices are :class:`DVertex` objects, or instances of the subclass given
25452545 as ``vertex_class``. Edges are :class:`Edge` objects, or instances of the
2546- subclass given as ``edge_class``; see :class:`_BaseGraph ` for the
2546+ subclass given as ``edge_class``; see :class:`BaseGraph ` for the
25472547 constructor arguments and the exceptions they raise.
25482548
25492549 .. inheritance-diagram:: DGraph
25502550
2551- :seealso: :class:`_BaseGraph ` :class:`UGraph`
2551+ :seealso: :class:`BaseGraph ` :class:`UGraph`
25522552 """
25532553
25542554 def _graphcolor (self ) -> int | None :
@@ -2654,7 +2654,7 @@ class Edge:
26542654 - Inheritance is an alternative to providing arbitrary user data.
26552655 - Pass the subclass as ``edge_class`` when constructing the graph and
26562656 the graph will create instances of it itself, see
2657- :class:`_BaseGraph `.
2657+ :class:`BaseGraph `.
26582658
26592659 An Edge points to a pair of vertices. At ``connect`` time the vertices
26602660 get references back to the Edge object.
@@ -2828,7 +2828,7 @@ def connect(self, v1: BaseVertex, v2: BaseVertex) -> None:
28282828 :raises ValueError: either vertex has not been added to a graph, or
28292829 the vertices belong to different graphs
28302830 :raises TypeError: this edge is not an instance of the graph's
2831- :attr:`_BaseGraph .edge_class`
2831+ :attr:`BaseGraph .edge_class`
28322832
28332833 The edge connects vertices ``v1`` and ``v2``, and is added to the
28342834 graph that those vertices belong to.
@@ -2948,13 +2948,13 @@ def remove(self) -> None:
29482948 ``e.remove()`` removes ``e`` from its graph's own edge collection and
29492949 from its connected vertices' edge lists (both, for an undirected
29502950 edge; the source only, for a directed one -- see
2951- :meth:`_BaseGraph .remove_edge`), and clears ``e.v1``/``e.v2`` to
2951+ :meth:`BaseGraph .remove_edge`), and clears ``e.v1``/``e.v2`` to
29522952 ``None``. The ``Edge`` object itself is not deleted -- it becomes an
29532953 orphaned, disconnected shell, and calling ``remove()`` on it again
29542954 raises ``ValueError``.
29552955
29562956 .. note:: This is a thin convenience wrapper around
2957- :meth:`_BaseGraph .remove_edge`.
2957+ :meth:`BaseGraph .remove_edge`.
29582958
29592959 :rtype: None
29602960
@@ -2968,7 +2968,7 @@ def remove(self) -> None:
29682968 >>> e.remove()
29692969 >>> print(g)
29702970
2971- :seealso: :meth:`_BaseGraph .remove_edge` :meth:`BaseVertex.remove`
2971+ :seealso: :meth:`BaseGraph .remove_edge` :meth:`BaseVertex.remove`
29722972 """
29732973 if self .v1 is None or self .v1 ._graph is None :
29742974 raise ValueError ("edge is not connected to a graph" )
@@ -3001,15 +3001,15 @@ def __init__(self, coord: ArrayLike | None = None, name: str | None = None):
30013001 :type name: str, optional
30023002
30033003 Creates a vertex but does not add it to a graph -- use
3004- :meth:`_BaseGraph .add_vertex` for that.
3004+ :meth:`BaseGraph .add_vertex` for that.
30053005
30063006 .. runblock:: pycon
30073007
30083008 >>> from pgraph import UVertex
30093009 >>> v1 = UVertex(coord=[0,0], name='v1')
30103010 >>> print(v1)
30113011
3012- :seealso: :meth:`_BaseGraph .add_vertex`
3012+ :seealso: :meth:`BaseGraph .add_vertex`
30133013 """
30143014 self ._edgelist : list [Edge ] = []
30153015 if coord is None :
@@ -3020,7 +3020,7 @@ def __init__(self, coord: ArrayLike | None = None, name: str | None = None):
30203020 self .label : int | None = None
30213021 self ._connectivitychange = True
30223022 self ._edgelist = []
3023- self ._graph : _BaseGraph | None = None # reference to owning graph
3023+ self ._graph : BaseGraph | None = None # reference to owning graph
30243024 # print('BaseVertex init', type(self))
30253025
30263026 def __str__ (self ) -> str :
@@ -3057,7 +3057,7 @@ def __repr__(self) -> str:
30573057 coord = ", " .join ([f"{ x :.4g} " for x in self .coord ])
30583058 return f"{ self .__class__ .__name__ } [{ self .name :s} , coord=({ coord } )]"
30593059
3060- def copy (self , cls : type [_BaseGraph ] | None = None ) -> BaseVertex :
3060+ def copy (self , cls : type [BaseGraph ] | None = None ) -> BaseVertex :
30613061 """
30623062 Copy a vertex
30633063
@@ -3094,7 +3094,7 @@ def adjacent(self) -> list[BaseVertex]:
30943094
30953095 ``v.adjacent()`` is a list of the vertices that this vertex is joined
30963096 to by an edge. "Adjacent" is the graph-theory term, and it is the
3097- relation that :meth:`_BaseGraph .adjacency` tabulates: row ``i`` of the
3097+ relation that :meth:`BaseGraph .adjacency` tabulates: row ``i`` of the
30983098 adjacency matrix is non-zero exactly at the columns of the vertices
30993099 returned by ``g[i].adjacent()``.
31003100
@@ -3120,7 +3120,7 @@ def adjacent(self) -> list[BaseVertex]:
31203120 >>> print(v1.adjacent())
31213121
31223122 :seealso: :meth:`isadjacent` :meth:`incidences` :meth:`edges`
3123- :meth:`_BaseGraph .adjacency`
3123+ :meth:`BaseGraph .adjacency`
31243124 """
31253125 return [e .next (self ) for e in self ._edgelist ]
31263126
@@ -3198,7 +3198,7 @@ def connect(
31983198 :param dest: The vertex to connect to
31993199 :type dest: ``BaseVertex`` subclass
32003200 :param edge: Use this as the edge object, otherwise a new object of the
3201- graph's :attr:`_BaseGraph .edge_class` is created from the
3201+ graph's :attr:`BaseGraph .edge_class` is created from the
32023202 vertices being connected, and the ``cost`` and ``data``
32033203 parameters, defaults to None
32043204 :type edge: ``Edge`` subclass, optional
@@ -3211,7 +3211,7 @@ def connect(
32113211 vertices belong to different graphs, or ``edge`` already connects
32123212 other vertices
32133213 :raises TypeError: ``edge`` is not an instance of the graph's
3214- :attr:`_BaseGraph .edge_class`
3214+ :attr:`BaseGraph .edge_class`
32153215 :return: the edge connecting the vertices
32163216 :rtype: Edge
32173217
@@ -3302,7 +3302,7 @@ def _detach(self, edge: Edge, dest: BaseVertex) -> None:
33023302 :raises NotImplementedError: not provided by this vertex kind
33033303
33043304 The twin of :meth:`_attach`: it undoes exactly what that recorded.
3305- Called by :meth:`_BaseGraph .remove_edge` before the edge's endpoints
3305+ Called by :meth:`BaseGraph .remove_edge` before the edge's endpoints
33063306 are cleared. An edge that is absent from a list is skipped rather
33073307 than treated as an error.
33083308 """
@@ -3409,7 +3409,7 @@ def heuristic_distance(self, v2: BaseVertex) -> float:
34093409 :rtype: float
34103410
34113411 Distance is computed according to the graph's heuristic, see
3412- :meth:`_BaseGraph .heuristic`. The vertex must belong to a graph,
3412+ :meth:`BaseGraph .heuristic`. The vertex must belong to a graph,
34133413 since the heuristic is a property of the graph, not the vertex.
34143414
34153415 .. runblock:: pycon
@@ -3420,7 +3420,7 @@ def heuristic_distance(self, v2: BaseVertex) -> float:
34203420 >>> v2 = g.add_vertex(coord=[4, 3], name='v2')
34213421 >>> print(v1.heuristic_distance(v2))
34223422
3423- :seealso: :meth:`distance` :meth:`_BaseGraph .heuristic`
3423+ :seealso: :meth:`distance` :meth:`BaseGraph .heuristic`
34243424 """
34253425 if self ._graph is None :
34263426 raise ValueError ("vertex is not connected to a graph" )
@@ -3569,7 +3569,7 @@ def closest(self) -> tuple[BaseVertex | None, float]:
35693569 >>> v4 = g.add_vertex(coord=[4,3], name='v4')
35703570 >>> print(v1.closest())
35713571
3572- :seealso: :meth:`_BaseGraph .closest`
3572+ :seealso: :meth:`BaseGraph .closest`
35733573 """
35743574 if self ._graph is None :
35753575 raise ValueError ("vertex is not connected to a graph" )
@@ -3588,7 +3588,7 @@ def remove(self) -> None:
35883588 not deleted.
35893589
35903590 .. note:: This is a thin convenience wrapper around
3591- :meth:`_BaseGraph .remove_vertex`.
3591+ :meth:`BaseGraph .remove_vertex`.
35923592
35933593 :rtype: None
35943594
@@ -3602,7 +3602,7 @@ def remove(self) -> None:
36023602 >>> v2.remove()
36033603 >>> print(g)
36043604
3605- :seealso: :meth:`_BaseGraph .remove_vertex` :meth:`Edge.remove`
3605+ :seealso: :meth:`BaseGraph .remove_vertex` :meth:`Edge.remove`
36063606 """
36073607 if self ._graph is None :
36083608 raise ValueError ("vertex is not connected to a graph" )
0 commit comments