Index: fedd/fedd_image.py
===================================================================
--- fedd/fedd_image.py	(revision 1f356d38533d830e355d1c226f24575c749d2427)
+++ fedd/fedd_image.py	(revision de86b35c905613801ea5af530f9f208d0b66baf8)
@@ -39,8 +39,8 @@
         self.add_option("--file", dest="file", 
                 help="experiment description file")
-	self.add_option("--group", dest="group", default=None, 
+	self.add_option("--group", dest="group", action="append", default=[], 
 		help="Group nodes by this attribute")
 
-def make_subgraph(topelems, attr):
+def make_subgraph(topelems, attrs):
     """
     Take a list of topdl elements (Computers and Substrates ) and partition
@@ -58,5 +58,8 @@
 	else: m[a] = [ v]
 
+    if not attrs: return { }
+
     sg = { }
+    attr, rest = attrs[0], attrs[1:]
     for e in topelems:
 	if isinstance(e, topdl.Computer):
@@ -73,24 +76,11 @@
 	    else: add_to_map(sg, 'default', e)
 
+    if rest:
+	for k in sg.keys():
+	    sg[k] = make_subgraph(sg[k], rest)
+
     return sg
 
-def gen_dot_topo(t, labels, dotfile, sg_attr=None):
-    """
-    Write a dot description of the topology in t, a topdl.Topology to the open
-    file dotfile.  the gen_image function below has already put some of that
-    file together. This function only generates the nodes and connections.  If
-    labels is true, label the nodes.
-    """
-
-
-    # The routine draws a circle for substrates with more than 2 interfaces
-    # connected to it, so this makes lists of each of those.
-    lans = [ s for s in t.substrates if len(s.interfaces) != 2]
-    links = [ s for s in t.substrates if len(s.interfaces) == 2]
-
-    # Break into subgraphs by the attribute of one's given
-    if sg_attr: sg = make_subgraph(t.elements + lans, sg_attr)
-    else: sg = { 'default': t.elements + lans }
-
+def output_subgraphs(sg, dotfile):
 
     # Construct subgraphs featurning nodes from those graphs
@@ -103,24 +93,49 @@
 	    print >>dotfile, 'label="%s"' % sn
 	else: 
-	    print >>dotfile, 'subgraph "%s" {' % sn
+	    print >>dotfile, 'subgraph {'
 	print >>dotfile, 'color="#08c0f8"'
 	print >>dotfile, 'clusterrank="local"'
 
-	# For each node in the subgraph, output its representation
-	for i, n in enumerate(nodes):
-	    if isinstance(n, topdl.Computer):
-		if n.name:
-		    print >>dotfile, '\t"%s" [shape=box,style=filled,\\' % \
-			    n.name
-		else:
+	if isinstance(nodes, dict): output_subgraphs(nodes, dotfile)
+	elif isinstance(nodes, list):
+	    # For each node in the subgraph, output its representation
+	    for i, n in enumerate(nodes):
+		if isinstance(n, topdl.Computer):
+		    if n.name:
+			print >>dotfile, \
+				'\t"%s" [shape=box,style=filled,\\' % n.name
+		    else:
+			print >>dotfile, \
+				'\t"unnamed_node%d" [shape=box,style=filled,\\'\
+				% i
 		    print >>dotfile, \
-			    '\t"unnamed_node%d" [shape=box,style=filled,\\' % i
-		print >>dotfile, \
-			'\t\tcolor=black,fillcolor="#60f8c0",regular=1]'
-	    elif isinstance(n, topdl.Substrate):
-		print >>dotfile, '\t"%s" [shape=ellipse, style=filled,\\' % \
-			n.name
-		print >>dotfile,'\t\tcolor=black,fillcolor="#80c0f8",regular=1]'
+			    '\t\tcolor=black,fillcolor="#60f8c0",regular=1]'
+		elif isinstance(n, topdl.Substrate):
+		    print >>dotfile, '\t"%s" [shape=ellipse, style=filled,\\' \
+			    % n.name
+		    print >>dotfile,\
+			    '\t\tcolor=black,fillcolor="#80c0f8",regular=1]'
 	print >>dotfile, '}'
+
+def gen_dot_topo(t, labels, dotfile, sg_attr):
+    """
+    Write a dot description of the topology in t, a topdl.Topology to the open
+    file dotfile.  the gen_image function below has already put some of that
+    file together. This function only generates the nodes and connections.  If
+    labels is true, label the nodes.
+    """
+
+
+    # The routine draws a circle for substrates with more than 2 interfaces
+    # connected to it, so this makes lists of each of those.
+    lans = [ s for s in t.substrates if len(s.interfaces) != 2]
+    links = [ s for s in t.substrates if len(s.interfaces) == 2]
+
+    # Break into subgraphs by the attribute of one's given
+    if sg_attr: sg = make_subgraph(t.elements + lans, sg_attr)
+    else: sg = { 'default': t.elements + lans }
+
+
+    output_subgraphs(sg, dotfile)
 
     # Pull the edges out ot the lans and links
@@ -205,9 +220,11 @@
     print >>dotfile, "graph G {"
     if dpi:
-	print >>dotfile, '\tgraph [size="%i,%i", dpi="%i", ratio=fill];' \
-		% (size, size, dpi)
+	print >>dotfile, \
+	    '\tgraph [size="%i,%i", dpi="%i", ratio=fill, compound="true"];' \
+	    % (size, size, dpi)
     else:
-	print >>dotfile, '\tgraph [size="%i,%i", ratio=fill, clusterrank="local"compound="true"];' \
-		% (size, size)
+	print >>dotfile, \
+	    '\tgraph [size="%i,%i", ratio=fill, compound="true"];' \
+	    % (size, size)
 
     if labels:
