Is there an easy way to ask if two graphs are isomorphic, respecting
some coloring or labeling of the vertices? I see the is_isomorphic
function lets you respect edge labels, so I guess I could attach a new
vertex to, say, all "blue" vertices, and label each of the edges to this
new vertex as "blue", then ask for edge-preserving isomorphism checking.
But it would be nice if there was a way to do this without modifying
the graph, etc.
Thanks,
Jason
I don't know if this is easy or not but here is an idea:
First, suppose you have 2 colors, red and blue. Compute the automorphism gp of
the graph, then look at the stabilizer of the red vertices. Done.
Next, if you have more colors, you compute the stablizer of each
individual color, then take the intersection of all the stabilizers you get.
> you respect edge labels, so I guess I could attach a new vertex to, say, all
> "blue" vertices, and label each of the edges to this new vertex as "blue",
> then ask for edge-preserving isomorphism checking. But it would be nice if
> there was a way to do this without modifying the graph, etc.
>
> Thanks,
>
> Jason
>
> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to
> sage-devel+...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
I've been working with nonisomorphic colorings recently. I use the following:
def canonical_coloring_label(G,c):
"""
Given a coloring dictionary,
{color1 : [u1, u2, ...], color2 : [v1, v2, ... ], ... }
return a string which uniquely identifies the isomorphism
class of the coloring.
"""
H = G.copy()
for i in c:
H.add_edges([(i,j) for j in c[i]])
P = [G.vertices(), c.keys()]
return H.canonical_label(partition=P).graph6_string()
I agree, it'd be nice to not have to do this. I've been talking with
Robert Miller to use the new canonical augmentation code to generate
nonisomorphic colorings.
With colorings, embeddings, and matchings, I wonder: should we create
classes to represent these objects instead of passing around naked
data structures? Then, it would make a lot of sense to have things
like coloring1.is_isomorphic(coloring2).
On Fri, Jan 6, 2012 at 9:43 AM, Jason Grout <jason...@creativetrax.com> wrote:
> Hi all,
>
> Is there an easy way to ask if two graphs are isomorphic, respecting some
> coloring or labeling of the vertices? I see the is_isomorphic function lets
I don't know if this is easy or not but here is an idea:
First, suppose you have 2 colors, red and blue. Compute the automorphism gp of
the graph, then look at the stabilizer of the red vertices. Done.
Next, if you have more colors, you compute the stablizer of each
individual color, then take the intersection of all the stabilizers you get.
Ah, right, I forgot about loops. Thanks to everyone with workarounds.
If we end up doing this project, I'll probably look at adding a switch
for vertex labels.
Thanks,
Jason