def setUp(self): """Constructs a simple graph to writes it into networkx then reads it back out. """ abstractTests.AbstractTestCase.setUp(self) sqg, graph = self.makeGraph(InMemoryArrayList) nxGraph, nxSubgraphList = networkxWrite(sqg) self.graphs = [(networkxRead(nxGraph, nxSubgraphList), graph)]
arrayLists.addDict({ "nodeName":arrayNode, "name":arrayListType, "arrayNames":" ".join(arrayList.getArrayNames()), "arrayTypes":" ".join(arrayList.getArrayTypes()) }) graphEdges.addDict({ "outNode":graphNode, "inNode":arrayNode }) #Add in the inherits edges for typeString in typeStringsToNodeNamesAndArrays.keys(): arrayNode, arrayList = typeStringsToNodeNamesAndArrays[typeString] if arrayList.getInherits() != None: parentArrayNode, parentArrayList = typeStringsToNodeNamesAndArrays[arrayList.getInherits().getType()] inheritEdges.addDict({ "outNode":parentArrayNode, "inNode":arrayNode }) #We're done print makeJsonSqgFromSqg(inheritanceGraph) #Here we dump a dot version of the graph, using the networkX interface. nxGraph, nxSubgraphs = networkxWrite(inheritanceGraph) for node in nxGraph.nodes(): nodeAtts = nxGraph.node[node] label = "%s [%s]" % (nodeAtts["name"], nodeAtts["type"]) if nodeAtts["type"] == "arrayLists": arrayTypes = nodeAtts["arrayTypes"].split() arrayNames = nodeAtts["arrayNames"].split() assert len(arrayTypes) == len(arrayNames) label = "{ %s | { " % label for i in range(len(arrayTypes)): label += "%s:%s" % (arrayNames[i], arrayTypes[i]) if i != len(arrayTypes) - 1: label += "|" label += "}}" nodeAtts["shape"] = "record" nodeAtts["color"] = "blue"