def testWriteToFile2(self): pw = PajekWriter() directory = PathDefaults.getOutputDir() + "test/" def setVertexColour(vertexIndex, graph): colours = ["grey05", "grey10", "grey15", "grey20", "grey25"] return colours[vertexIndex] def setVertexSize(vertexIndex, graph): return vertexIndex def setEdgeColour(vertexIndex1, vertexIndex2, graph): colours = ["grey05", "grey10", "grey15", "grey20", "grey25"] return colours[vertexIndex1] def setEdgeSize(vertexIndex1, vertexIndex2, graph): return vertexIndex1+vertexIndex2 pw.setVertexColourFunction(setVertexColour) fileName1 = directory + "vertexColourTest" pw.writeToFile(fileName1, self.dGraph1) pw.setVertexColourFunction(None) pw.setVertexSizeFunction(setVertexSize) fileName1 = directory + "vertexSizeTest" pw.writeToFile(fileName1, self.dGraph1) pw.setVertexSizeFunction(None) pw.setEdgeColourFunction(setEdgeColour) fileName1 = directory + "edgeColourTest" pw.writeToFile(fileName1, self.dGraph1) pw.setEdgeColourFunction(None) pw.setEdgeSizeFunction(setEdgeSize) fileName1 = directory + "edgeSizeTest" pw.writeToFile(fileName1, self.dGraph1) pw.setEdgeColourFunction(None)
def testWriteToFile2(self): pw = PajekWriter() directory = PathDefaults.getOutputDir() + "test/" def setVertexColour(vertexIndex, graph): colours = ["grey05", "grey10", "grey15", "grey20", "grey25"] return colours[vertexIndex] def setVertexSize(vertexIndex, graph): return vertexIndex def setEdgeColour(vertexIndex1, vertexIndex2, graph): colours = ["grey05", "grey10", "grey15", "grey20", "grey25"] return colours[vertexIndex1] def setEdgeSize(vertexIndex1, vertexIndex2, graph): return vertexIndex1 + vertexIndex2 pw.setVertexColourFunction(setVertexColour) fileName1 = directory + "vertexColourTest" pw.writeToFile(fileName1, self.dGraph1) pw.setVertexColourFunction(None) pw.setVertexSizeFunction(setVertexSize) fileName1 = directory + "vertexSizeTest" pw.writeToFile(fileName1, self.dGraph1) pw.setVertexSizeFunction(None) pw.setEdgeColourFunction(setEdgeColour) fileName1 = directory + "edgeColourTest" pw.writeToFile(fileName1, self.dGraph1) pw.setEdgeColourFunction(None) pw.setEdgeSizeFunction(setEdgeSize) fileName1 = directory + "edgeSizeTest" pw.writeToFile(fileName1, self.dGraph1) pw.setEdgeColourFunction(None)
from apgl.viroscopy.HIVGraphReader import HIVGraphReader from apgl.io.PajekWriter import PajekWriter from apgl.util import * import logging import sys import math logging.basicConfig(stream=sys.stdout, level=logging.INFO) """ A script to load up the HIV data in its entirity. """ hivReader = HIVGraphReader() graph = hivReader.readHIVGraph() def getVertexSize(vertexIndex, graph): return math.sqrt(len(graph.neighbours(vertexIndex))) def getEdgeWeight(vertexIndex1, vertexIndex2, graph): return graph.getEdge(vertexIndex1, vertexIndex2, 0) outputDirectory = PathDefaults.getOutputDir() fileName = outputDirectory + "hivGraph" pajekWriter = PajekWriter() pajekWriter.setVertexSizeFunction(getVertexSize) pajekWriter.setEdgeWeightFunction(getEdgeWeight) pajekWriter.writeToFile(fileName, graph)