Skip to content

Commit 03f9faa

Browse files
committed
refactor: Graph.are_connected() was renamed to Graph.are_adjacent()
1 parent bafd4a6 commit 03f9faa

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
allows the user to strip the `g_`, `v_` and `e_` prefixes from GraphML files
99
written by igraph.
1010

11+
### Changed
12+
13+
- `Graph.are_connected()` has now been renamed to `Graph.are_adjacent()`,
14+
following up a similar change in the C core. The old name of the function
15+
is deprecated but will be kept around until at least 0.12.0.
16+
1117
## [0.11.4]
1218

1319
### Added

doc/source/analysis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ To get the vertices at the two ends of an edge, use :attr:`Edge.source` and :att
6363
>>> v1, v2 = e.source, e.target
6464

6565
Vice versa, to get the edge if from the source and target vertices, you can use :meth:`Graph.get_eid` or, for multiple pairs of source/targets,
66-
:meth:`Graph.get_eids`. The boolean version, asking whether two vertices are directly connected, is :meth:`Graph.are_connected`.
66+
:meth:`Graph.get_eids`. The boolean version, asking whether two vertices are directly connected, is :meth:`Graph.are_adjacent`.
6767

6868
To get the edges incident on a vertex, you can use :meth:`Vertex.incident`, :meth:`Vertex.out_edges` and
6969
:meth:`Vertex.in_edges`. The three are equivalent on undirected graphs but not directed ones of course::

src/_igraph/graphobject.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,10 +1445,10 @@ PyObject *igraphmodule_Graph_is_biconnected(igraphmodule_GraphObject *self, PyOb
14451445
/** \ingroup python_interface_graph
14461446
* \brief Decides whether there is an edge from a given vertex to an other one.
14471447
* \return Py_True if the vertices are directly connected, Py_False otherwise
1448-
* \sa igraph_are_connected
1448+
* \sa igraph_are_adjacent
14491449
*/
1450-
PyObject *igraphmodule_Graph_are_connected(igraphmodule_GraphObject * self,
1451-
PyObject * args, PyObject * kwds)
1450+
PyObject *igraphmodule_Graph_are_adjacent(igraphmodule_GraphObject * self,
1451+
PyObject * args, PyObject * kwds)
14521452
{
14531453
static char *kwlist[] = { "v1", "v2", NULL };
14541454
PyObject *v1, *v2;
@@ -1464,7 +1464,7 @@ PyObject *igraphmodule_Graph_are_connected(igraphmodule_GraphObject * self,
14641464
if (igraphmodule_PyObject_to_vid(v2, &idx2, &self->g))
14651465
return NULL;
14661466

1467-
if (igraph_are_connected(&self->g, idx1, idx2, &res))
1467+
if (igraph_are_adjacent(&self->g, idx1, idx2, &res))
14681468
return igraphmodule_handle_igraph_error();
14691469

14701470
if (res)
@@ -14554,10 +14554,10 @@ struct PyMethodDef igraphmodule_Graph_methods[] = {
1455414554
// STRUCTURAL PROPERTIES OF GRAPHS //
1455514555
/////////////////////////////////////
1455614556

14557-
// interface to igraph_are_connected
14558-
{"are_connected", (PyCFunction) igraphmodule_Graph_are_connected,
14557+
// interface to igraph_are_adjacent
14558+
{"are_adjacent", (PyCFunction) igraphmodule_Graph_are_adjacent,
1455914559
METH_VARARGS | METH_KEYWORDS,
14560-
"are_connected(v1, v2)\n--\n\n"
14560+
"are_adjacent(v1, v2)\n--\n\n"
1456114561
"Decides whether two given vertices are directly connected.\n\n"
1456214562
"@param v1: the ID or name of the first vertex\n"
1456314563
"@param v2: the ID or name of the second vertex\n"

src/igraph/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,14 @@ def Incidence(cls, *args, **kwds):
948948
deprecated("Graph.Incidence() is deprecated; use Graph.Biadjacency() instead")
949949
return cls.Biadjacency(*args, **kwds)
950950

951+
def are_connected(self, *args, **kwds):
952+
"""Deprecated alias to L{Graph.are_adjacent()}."""
953+
deprecated(
954+
"Graph.are_connected() is deprecated; use Graph.are_adjacent() "
955+
"instead"
956+
)
957+
return self.are_adjacent(*args, **kwds)
958+
951959
def get_incidence(self, *args, **kwds):
952960
"""Deprecated alias to L{Graph.get_biadjacency()}."""
953961
deprecated(

tests/test_attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def testVertexNameIndexingBug196(self):
112112
g.add_vertices([a, b])
113113
g.add_edges([(a, b)])
114114
self.assertEqual(g.ecount(), 1)
115-
self.assertTrue(g.are_connected(a, b))
115+
self.assertTrue(g.are_adjacent(a, b))
116116

117117
def testInvalidAttributeNames(self):
118118
g = Graph.Famous("bull")

tests/test_structural.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ def testGetAllSimplePaths(self):
994994
self.assertEqual(15, path[-1])
995995
curr = path[0]
996996
for next in path[1:]:
997-
self.assertTrue(g.are_connected(curr, next))
997+
self.assertTrue(g.are_adjacent(curr, next))
998998
curr = next
999999

10001000
def testPathLengthHist(self):

0 commit comments

Comments
 (0)