예제 #1
0
adjacencyEdges.addDict({ "node1":cR, "node2":dL, "overlap":-1})
adjacencyEdges.addDict({ "node1":dR, "node2":_2, "overlap":0})
for node1, node2, overlap in adjacencyEdges:
	print "node1", node1, "node2", node2, "overlap", overlap

mixedSubgraphs = InMemoryArrayList(type="mixedSubgraph")
mixedSubgraphs.getArrayNames()
mixedSubgraphs.getArrayTypes()

mixedSubgraphs.getSharedVariables()

walks = InMemoryArrayList(type="walk", inherits="mixedSubgraph", variables=[ "start", "int", "stop", "int" ], sharedVariables={ "edges":[ "segmentEdge", "adjacencyEdge" ] })
sqg.setArrayList(walks)
walks.getArrayNames()
walks.getArrayTypes()

walks.addDict({ "subgraphName":0, "nodes":[ _1, aL, aR, b1L, b1R, b1L, b1R, cR, cL, b2R, b2L, cL, cR, dL, dR, _2 ], "start":0, "stop":0 })
walks.addDict({ "subgraphName":1, "nodes":[ aL, aR, b1L, b1R, b1L, b1R, cR, cL, b2L, b2R, cL, cR, dL, dR ], "start":3, "stop":10 })

from pysqg.jsonSqg import makeJsonSqgFromSqg
jsonSqg = makeJsonSqgFromSqg(sqg)
print jsonSqg
from pysqg.jsonSqg import makeSqgFromJsonSqg
makeSqgFromJsonSqg(jsonSqg)
makeJsonSqgFromSqg(sqg, putOnDiskArraysInJsonSqg=True)

import os
os.remove("./segmentEdges")
os.remove("./adjacencyEdges")

예제 #2
0
def main():
	jsonGraph = makeJsonSqgFromSqg(fastgToSqg(sys.stdin))
	json.dump(jsonGraph, sys.stdout)
예제 #3
0
                arrayNode = i
                i = i+1
                typeStringsToNodeNamesAndArrays[arrayListType] = (arrayNode, arrayList)
                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 += "|"