summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraric <none@none>2007-04-12 04:22:03 +0000
committeraric <none@none>2007-04-12 04:22:03 +0000
commite9b046edab30fb823782094d4f9924d80925bc23 (patch)
treec5fef742be0a1c6f762c25da35dcad46d966cc23
parent8fe6d2d8f82d0ef8b01d42e13f1d825867ce8797 (diff)
downloadnetworkx-e9b046edab30fb823782094d4f9924d80925bc23.tar.gz
Add is_isomorphic to __init__.py
Simpler is_isomorphic function until other algorithms are implemented Cleanup of header in isomorphvf2 --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40565
-rwxr-xr-xnetworkx/__init__.py1
-rw-r--r--networkx/isomorph.py27
-rw-r--r--networkx/isomorphvf2.py15
3 files changed, 18 insertions, 25 deletions
diff --git a/networkx/__init__.py b/networkx/__init__.py
index f40822a8..a3ccc651 100755
--- a/networkx/__init__.py
+++ b/networkx/__init__.py
@@ -90,6 +90,7 @@ from cliques import find_cliques, make_max_clique_graph,\
make_clique_bipartite,graph_clique_number,\
graph_number_of_cliques,node_clique_number,\
number_of_cliques,cliques_containing_node
+from isomorph import is_isomorphic
# need numpy for spectrum
try:
diff --git a/networkx/isomorph.py b/networkx/isomorph.py
index 7485608f..46f02189 100644
--- a/networkx/isomorph.py
+++ b/networkx/isomorph.py
@@ -99,28 +99,21 @@ def faster_graph_could_be_isomorphic(G1,G2):
# OK...
return True
-def is_isomorphic(G1,G2,**kwds):
- """Returns True if the graphs are isomorphic and False if the graphs are not
- isomorphic. The keyword 'algorithm' can be used to specify a particular
- algorithm. Allowable algorithms are:
-
- algorithm='vf2'
-
- The default algorithm is 'vf2'.
+def is_isomorphic(G1,G2):
+ """Returns True if the graphs G1 and G2 are isomorphic and False otherwise.
+
+ Uses the vf2 algorithm - see networkx.isomorphvf2
"""
- algorithm = kwds.get('algorithm','vf2')
-
- if algorithm == 'vf2':
- if G1.is_directed() and G2.is_directed():
- return networkx.isomorphvf2.DiGraphMatcher(G1,G2).is_isomorphic()
- elif not (G1.is_directed() and G2.is_directed()):
- return networkx.isomorphvf2.GraphMatcher(G1,G2).is_isomorphic()
- else:
+ if G1.is_directed() and G2.is_directed():
+ return networkx.isomorphvf2.DiGraphMatcher(G1,G2).is_isomorphic()
+ elif not (G1.is_directed() and G2.is_directed()):
+ return networkx.isomorphvf2.GraphMatcher(G1,G2).is_isomorphic()
+ else:
# Graphs are of mixed type. We could just return False,
# but then there is the case of completely disconnected graphs...
# which could be isomorphic.
- raise NetworkXError, "Both graphs were not directed or both graphs were not undirected."
+ raise NetworkXError, "Both graphs were not directed or both graphs were not undirected."
diff --git a/networkx/isomorphvf2.py b/networkx/isomorphvf2.py
index 172972c7..7c04da95 100644
--- a/networkx/isomorphvf2.py
+++ b/networkx/isomorphvf2.py
@@ -10,19 +10,20 @@ Modified to handle undirected graphs.
Modified to handle multiple edges.
"""
-__date__ = "$Date:$"
+__date__ = "$Date$"
__credits__ = "$Credits:$"
-__revision__ = "$Revision:$"
+__revision__ = "$Revision$"
# Copyright (C) 2007 by
# Christopher Ellison <cellison@cse.ucdavis.edu>
# Distributed under the terms of the GNU Lesser General Public License
# http://www.gnu.org/copyleft/lesser.html
#
-# This work was completed as part of the Computational Mechanics Python (CMPy) project.
-# James P. Crutchfield, principal investigator.
-# Center for Computational Science and Engineering and Physics Department, UC Davis.
-#
+# This work was completed as part of the
+# Computational Mechanics Python (CMPy) project.
+# James P. Crutchfield, principal investigator.
+# Center for Computational Science and Engineering and Physics Department,
+# UC Davis.
import sys
from sets import Set
@@ -46,8 +47,6 @@ class GraphMatcher(object):
For more information, see the docmentation for:
syntactic_feasibliity()
semantic_feasibility()
-
-
Suppose G1 and G2 are isomorphic graphs. Verification is as follows: