Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
1

Algorithm implementation in Sage

asked 12 years ago

Mohab gravatar image

updated 1 year ago

FrédéricC gravatar image

Input: Two undirected simple graphs G1 and G2, each having n vertices. Output: True if G1 ? = G2; False otherwise.

for i ? 1,2 do
  Ai ? adjacency matrix of Gi
  pi ? permutation equivalence class of Ai
  A0 i ? lexicographically maximal element of pi
if A0 1 = A0 2 then
  return True
return False

anyone have any idea how to implement this in Sage ?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 12 years ago

fidbc gravatar image

You can test if G1G2 using the following function f.

sage: f = lambda g,h: g.is_isomorphic(h)
sage: G = graphs.CubeGraph(3)
sage: H = graphs.HexahedralGraph()
sage: f(G,H)
True

If you really want to use the canonical label then, given a Graph g, you can obtain it by using g.canonical_label() and then just compare the adjacency matrices.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 467 times

Last updated: Mar 14 '13