Ejemplo n.º 1
0
 def test_mst_kruskal(self):
     sn = self.simpleWeightedNet
     sn_minST = netio.loadNet(
         self.folder +
         "testData/transforms/simpleWeightedNet_minSpanningTree.edg")
     self.assertEqual(sorted(transforms.mst_kruskal(sn)), sorted(sn_minST))
Ejemplo n.º 2
0
    def setUp(self):
        self.folder=os.path.dirname(netio.__file__)+os.path.join("a","tests","")[1:]
        self.simpleWeightedNet=netio.loadNet(self.folder+"testData/simpleWeightedNet.edg")

        self.sn_properties1=self.folder+"testData/nodeProperties/simpleWeightedNet_properties1.txt"
        self.sn_properties1_nolabels=self.folder+"testData/nodeProperties/simpleWeightedNet_properties1_nolabels.txt"                
Ejemplo n.º 3
0
 def setUp(self):
     self.folder = os.path.dirname(transforms.__file__) + os.path.join(
         "a", "tests", "")[1:]
     self.simpleWeightedNet = netio.loadNet(
         self.folder + "testData/simpleWeightedNet.edg")
Ejemplo n.º 4
0
if __name__ == '__main__':
    # List of currently accepted formats.
    in_formats = ('edg',)
    out_formats = ('edg', 'mat', 'gml', 'net')

    # Get the input and output file names. If anything goes wrong,
    # print the documentation and exit.
    try:
        inputFormat = sys.argv[1]
        outputFormat = sys.argv[2]
        if len(sys.argv) > 3:
            behaviour = sys.argv[3]
        else:
            behaviour = 'simple'
        if not (inputFormat in in_formats and
                outputFormat in out_formats and 
                behaviour in ('simple', 'mutual')):
            raise
    except:
        sys.stderr.write(__doc__)
        exit(1)

    mE = (True if behaviour == 'mutual' else False)

    # Read in the network and write it out.
    netio.writeNet(netio.loadNet(sys.stdin, fileType=inputFormat, 
                                 numerical=True, mutualEdges=mE,
                                 allowSelfEdges=False),
                   sys.stdout, fileType=outputFormat)
Ejemplo n.º 5
0
        The network under `nc`.
    """
    print_statistics(nc, ncName, net)
    plot_commSizeDist(nc, ncName)
    if net is not None:
        plot_avgCommWeight(nc, ncName, net)


if __name__ == '__main__':
    # Read in the community structure.
    try:
        commFileName = sys.argv[1]
        ncName = sys.argv[2]
        netFileName = ""
        if len(sys.argv) > 3:
            netFileName = sys.argv[3]
    except:
        sys.stderr.write(__doc__)

    # Read in the community structure.
    with open(commFileName, 'r') as f:
        nc = communities.NodeCover(inputFile=f)

    # Read in the network (if given)
    net = None
    if netFileName:
        net = netio.loadNet(netFileName)

    # Plot everything.
    plot_all(nc, ncName, net)
Ejemplo n.º 6
0
        The network under `nc`.
    """
    print_statistics(nc, ncName, net)
    plot_commSizeDist(nc, ncName)
    if net is not None:
        plot_avgCommWeight(nc, ncName, net)

if __name__ == '__main__':
    # Read in the community structure.
    try:
        commFileName = sys.argv[1]
        ncName = sys.argv[2]
        netFileName = ""
        if len(sys.argv) > 3:
            netFileName = sys.argv[3]
    except:
        sys.stderr.write(__doc__)

    # Read in the community structure.
    with open(commFileName, 'r') as f:
        nc = communities.NodeCover(inputFile=f)

    # Read in the network (if given)
    net = None
    if netFileName:
        net = netio.loadNet(netFileName)

    # Plot everything.
    plot_all(nc, ncName, net)

Ejemplo n.º 7
0
	def test_mst_kruskal(self):
		sn=self.simpleWeightedNet
		sn_minST=netio.loadNet(self.folder+"testData/transforms/simpleWeightedNet_minSpanningTree.edg")
		self.assertEqual(sorted(transforms.mst_kruskal(sn)),sorted(sn_minST))
Ejemplo n.º 8
0
	def setUp(self):
		self.folder=os.path.dirname(transforms.__file__)+os.path.join("a","tests","")[1:]
		self.simpleWeightedNet=netio.loadNet(self.folder+"testData/simpleWeightedNet.edg")