CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download
Project: MAT 2540
Views: 65
Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2004
Kernel: Python 3 (Anaconda 2020)
import networkx as nx
G1 = nx.Graph()
G1.add_nodes_from('abcdefgh')
s1 = ['ab','bc','cd','da','dh','bf','ef','fg','gh','he']
for s in s1: G1.add_edge(s[0],s[1])
nx.draw(G1,with_labels=True)
Image in a Jupyter notebook
G2 = nx.Graph()
G2.add_nodes_from('stuvwxyz')
s2 = ['st','tu','uv','vs','vz','zw','wx','xy','yz','ws']
for s in s2: G2.add_edge(s[0],s[1])
nx.draw(G2,with_labels=True)
Image in a Jupyter notebook
nx.faster_could_be_isomorphic(G1,G2)
True
nx.fast_could_be_isomorphic(G1,G2)
True
nx.could_be_isomorphic(G1,G2)
True
nx.is_isomorphic(G1,G2)
False
for path in nx.all_simple_paths(G1,'a','a'): print(path)