def createLinkClass(self, label, attributes):
        def create(origin, destination):
            link = compounds.Link(origin, destination)
            link.attr._Attributes__attr.update(attributes)
            return link

        n1 = compounds.Node(raw.makeId(label) + "_1").set("style", "invis").set("shape", "point")
        n2 = compounds.Node(raw.makeId(label) + "_2").set("style", "invis").set("shape", "point")
        self.__legend.add(n1).add(n2).add(create(n1, n2).set("label", label))

        return create
    def createNodeClass(self, label, attributes):
        def create(id):
            node = compounds.Node(id)
            node.attr._Attributes__attr.update(attributes)
            return node

        self.__legend.add(create(raw.makeId(label)).set("label", label))

        return create
 def testReplaceStrangeCharacters(self):
     self.assertEqual(gv.makeId("#"), "_23")
     self.assertEqual(gv.makeId("_"), "_5f")
     self.assertEqual(gv.makeId("*"), "_2a")
     self.assertEqual(gv.makeId(" "), "_20")
     self.assertEqual(gv.makeId("\2"), "_02")
     self.assertEqual(gv.makeId("\""), "_22")
 def testTuple(self):
     self.assertEqual(gv.makeId((42, "a")), "_2842_2c_20_27a_27_29")
 def testNone(self):
     self.assertEqual(gv.makeId(None), "None")
 def testInteger(self):
     self.assertEqual(gv.makeId(57), "_357")
 def testDontStartWithDigit(self):
     self.assertEqual(gv.makeId("57a"), "_357a")
 def testKeepDigits(self):
     self.assertEqual(gv.makeId("a0123456789"), "a0123456789")
 def testKeepLetters(self):
     self.assertEqual(gv.makeId("abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz")
     self.assertEqual(gv.makeId("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")