<s> from apgl . graph . VertexList import VertexList <EOL> from apgl . graph . GeneralVertexList import GeneralVertexList <EOL> from apgl . generator . BarabasiAlbertGenerator import BarabasiAlbertGenerator <EOL> from apgl . util . PathDefaults import PathDefaults <EOL> import numpy <EOL> import os <EOL> import logging <EOL> import pickle <EOL> import numpy . testing as nptst <EOL> """<STR_LIT>""" <EOL> class MatrixGraphTest ( ) : <EOL> def initialise ( self ) : <EOL> numpy . set_printoptions ( suppress = True ) <EOL> numpy . random . seed ( <NUM_LIT> ) <EOL> self . numVertices = <NUM_LIT:6> <EOL> self . numFeatures = <NUM_LIT:1> <EOL> self . vList = VertexList ( self . numVertices , self . numFeatures ) <EOL> self . graph = self . GraphType ( self . vList ) <EOL> self . graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> self . graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> self . graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> self . graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> self . graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> self . graph2 = self . GraphType ( self . vList , False ) <EOL> self . graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . graph2 . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> self . graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> self . graph2 . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> self . graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> self . graph2 . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> def testAddEdge ( self ) : <EOL> self . graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> ) <EOL> self . assertEquals ( self . graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( self . graph . getEdge ( <NUM_LIT:5> , <NUM_LIT:1> ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( self . graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:5> ) , None ) <EOL> self . assertRaises ( ValueError , self . graph . addEdge , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0> ) <EOL> def testAddEdges ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vList . setVertices ( numpy . random . rand ( numVertices , numFeatures ) ) <EOL> graph = self . GraphType ( vList ) <EOL> edgeIndexArray = numpy . array ( [ [ <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:2> , <NUM_LIT:3> ] ] ) <EOL> graph . addEdges ( edgeIndexArray ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:2> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdges ( edgeIndexArray ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> edgeValues = numpy . array ( [ <NUM_LIT:0.1> , <NUM_LIT> ] ) <EOL> graph . addEdges ( edgeIndexArray , edgeValues ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) , <NUM_LIT> ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdges ( edgeIndexArray , edgeValues ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) , <NUM_LIT> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) , <NUM_LIT> ) <EOL> edgeValues = numpy . array ( [ <NUM_LIT:0.1> , <NUM_LIT:0.0> ] ) <EOL> self . assertRaises ( ValueError , graph . addEdges , edgeIndexArray , edgeValues ) <EOL> def testRemoveEdge ( self ) : <EOL> self . graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> ) <EOL> self . assertEquals ( self . graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( self . graph . getEdge ( <NUM_LIT:5> , <NUM_LIT:1> ) , <NUM_LIT:2> ) <EOL> self . graph . removeEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> self . assertEquals ( self . graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) , None ) <EOL> self . assertEquals ( self . graph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , None ) <EOL> def testNeighbours ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:9> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( numpy . sort ( graph . neighbours ( <NUM_LIT:1> ) ) == numpy . array ( [ <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:9> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbours ( <NUM_LIT:2> ) == numpy . array ( [ <NUM_LIT:3> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( numpy . sort ( graph . neighbours ( <NUM_LIT:3> ) ) == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbours ( <NUM_LIT:4> ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:9> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( numpy . sort ( graph . neighbours ( <NUM_LIT:1> ) ) == numpy . array ( [ <NUM_LIT:3> , <NUM_LIT:5> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbours ( <NUM_LIT:2> ) == numpy . array ( [ <NUM_LIT:3> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbours ( <NUM_LIT:3> ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbours ( <NUM_LIT:9> ) == numpy . array ( [ <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> def testNeighbourOf ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:9> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . neighbourOf ( <NUM_LIT:1> ) == numpy . array ( [ <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:9> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbourOf ( <NUM_LIT:2> ) == numpy . array ( [ <NUM_LIT:3> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbourOf ( <NUM_LIT:3> ) == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbourOf ( <NUM_LIT:4> ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:9> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . neighbourOf ( <NUM_LIT:1> ) == numpy . array ( [ <NUM_LIT:9> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbourOf ( <NUM_LIT:2> ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbourOf ( <NUM_LIT:3> ) == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . neighbourOf ( <NUM_LIT:9> ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> def testClusteringCoefficient ( self ) : <EOL> numVertices = <NUM_LIT:3> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> self . assertEqual ( graph . clusteringCoefficient ( ) , <NUM_LIT:0> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> self . assertEqual ( graph . clusteringCoefficient ( ) , <NUM_LIT:1> ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> self . assertEqual ( graph . clusteringCoefficient ( ) , float ( <NUM_LIT:3> ) / <NUM_LIT:8> ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> self . assertEqual ( graph . clusteringCoefficient ( ) , <NUM_LIT:0.0> ) <EOL> def testDegreeDistribution ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> self . assertTrue ( ( graph . degreeDistribution ( ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . degreeDistribution ( ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> self . assertTrue ( ( graph . degreeDistribution ( ) == numpy . array ( [ <NUM_LIT:5> ] ) ) . all ( ) ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . degreeDistribution ( ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> subGraph = graph . subgraph ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> def testDijkstrasAlgorithm ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . dijkstrasAlgorithm ( <NUM_LIT:0> ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . dijkstrasAlgorithm ( <NUM_LIT:1> ) == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . dijkstrasAlgorithm ( <NUM_LIT:2> ) == numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . dijkstrasAlgorithm ( <NUM_LIT:3> ) == numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:3> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . dijkstrasAlgorithm ( <NUM_LIT:4> ) == numpy . array ( [ <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( self . graph . dijkstrasAlgorithm ( <NUM_LIT:2> , self . graph . adjacencyList ( ) ) == numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:3> , float ( '<STR_LIT>' ) ] ) ) . all ( ) ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . dijkstrasAlgorithm ( <NUM_LIT:0> ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , numpy . inf ] ) ) . all ( ) ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . dijkstrasAlgorithm ( <NUM_LIT:0> ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> def testGeodesicDistance ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> P = graph . floydWarshall ( ) <EOL> self . assertEquals ( graph . geodesicDistance ( ) , <NUM_LIT> / <NUM_LIT> ) <EOL> self . assertEquals ( graph . geodesicDistance ( P ) , <NUM_LIT> / <NUM_LIT> ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> P = graph . floydWarshall ( ) <EOL> self . assertEquals ( graph . geodesicDistance ( ) , <NUM_LIT> / <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . geodesicDistance ( P ) , <NUM_LIT> / <NUM_LIT:3> ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> P = graph . floydWarshall ( ) <EOL> self . assertEquals ( graph . geodesicDistance ( ) , <NUM_LIT> / <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . geodesicDistance ( P ) , <NUM_LIT> / <NUM_LIT:3> ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> P = graph . floydWarshall ( ) <EOL> self . assertEquals ( graph . geodesicDistance ( ) , <NUM_LIT> / <NUM_LIT> ) <EOL> self . assertEquals ( graph . geodesicDistance ( P ) , <NUM_LIT> / <NUM_LIT> ) <EOL> def testHopCount ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> self . assertTrue ( ( graph . hopCount ( ) == numpy . array ( [ <NUM_LIT:10> , <NUM_LIT:16> , <NUM_LIT> ] ) ) . all ( ) ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> ) <EOL> self . assertTrue ( ( graph . hopCount ( ) == numpy . array ( [ <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:30> ] ) ) . all ( ) ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> self . assertTrue ( ( graph . hopCount ( ) == numpy . array ( [ <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> ] ) ) . all ( ) ) <EOL> P = graph . floydWarshall ( ) <EOL> self . assertTrue ( ( graph . hopCount ( P ) == numpy . array ( [ <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> ] ) ) . all ( ) ) <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> self . assertTrue ( ( graph . hopCount ( ) == numpy . array ( [ <NUM_LIT:10> , <NUM_LIT> ] ) ) . all ( ) ) <EOL> P = graph . floydWarshall ( False ) <EOL> self . assertTrue ( ( graph . hopCount ( P ) == numpy . array ( [ <NUM_LIT:10> , <NUM_LIT> ] ) ) . all ( ) ) <EOL> graph = self . GraphType ( vList , True ) <EOL> self . assertTrue ( ( graph . hopCount ( ) == numpy . array ( [ numVertices ] ) ) . all ( ) ) <EOL> vList = VertexList ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> graph = self . GraphType ( vList , True ) <EOL> self . assertTrue ( ( graph . hopCount ( ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> def testHarmonicGeodesicDistance ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . harmonicGeodesicDistance ( ) , <NUM_LIT> ) <EOL> P = graph . floydWarshall ( True ) <EOL> self . assertEquals ( graph . harmonicGeodesicDistance ( P ) , <NUM_LIT> ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> self . assertAlmostEquals ( graph . harmonicGeodesicDistance ( ) , <NUM_LIT> / <NUM_LIT> , places = <NUM_LIT:5> ) <EOL> P = graph . floydWarshall ( True ) <EOL> self . assertAlmostEquals ( graph . harmonicGeodesicDistance ( P ) , <NUM_LIT> / <NUM_LIT> , places = <NUM_LIT:5> ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> self . assertAlmostEquals ( graph . harmonicGeodesicDistance ( ) , <NUM_LIT> / <NUM_LIT> , places = <NUM_LIT:5> ) <EOL> P = graph . floydWarshall ( True ) <EOL> self . assertAlmostEquals ( graph . harmonicGeodesicDistance ( P ) , <NUM_LIT> / <NUM_LIT> , places = <NUM_LIT:5> ) <EOL> graph = self . GraphType ( vList ) <EOL> self . assertEquals ( graph . harmonicGeodesicDistance ( ) , float ( '<STR_LIT>' ) ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> P = graph . floydWarshall ( True ) <EOL> inds = [ <NUM_LIT:0> , <NUM_LIT:4> ] <EOL> self . assertEquals ( graph . harmonicGeodesicDistance ( vertexInds = inds ) , <NUM_LIT> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> P = graph . floydWarshall ( True ) <EOL> self . assertAlmostEquals ( graph . harmonicGeodesicDistance ( P ) , <NUM_LIT> / <NUM_LIT> , places = <NUM_LIT:5> ) <EOL> def testGetAllEdges ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> edges = graph . getAllEdges ( ) <EOL> self . assertEquals ( edges . shape [ <NUM_LIT:0> ] , <NUM_LIT:4> ) <EOL> self . assertTrue ( ( edges [ <NUM_LIT:0> , : ] == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:0> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( edges [ <NUM_LIT:1> , : ] == numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( edges [ <NUM_LIT:2> , : ] == numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:2> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( edges [ <NUM_LIT:3> , : ] == numpy . array ( [ <NUM_LIT:3> , <NUM_LIT:2> ] ) ) . all ( ) ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> edges = graph . getAllEdges ( ) <EOL> edgeSet = set ( [ ( x , y ) for x , y in edges ] ) <EOL> edgeSet2 = set ( [ ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:3> ) ] ) <EOL> self . assertEquals ( edges . shape [ <NUM_LIT:0> ] , <NUM_LIT:5> ) <EOL> self . assertEquals ( edgeSet , edgeSet2 ) <EOL> graph = self . GraphType ( vList ) <EOL> edges = graph . getAllEdges ( ) <EOL> self . assertEquals ( edges . shape , ( <NUM_LIT:0> , <NUM_LIT:2> ) ) <EOL> def testGetNumEdges ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:8> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:8> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:4> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:8> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:8> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:4> ) <EOL> def testGetNumVertices ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> self . assertEquals ( graph . getNumVertices ( ) , numVertices ) <EOL> def testGetEdge ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:8> , <NUM_LIT> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:5> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:4> , <NUM_LIT:8> ) , <NUM_LIT> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:8> , <NUM_LIT:4> ) , <NUM_LIT> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:4> , <NUM_LIT:4> ) , None ) <EOL> def testGetVertex ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . setVertex ( <NUM_LIT:1> , numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:2> ] ) ) <EOL> self . assertRaises ( ValueError , graph . setVertex , - <NUM_LIT:1> , numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:2> ] ) ) <EOL> self . assertRaises ( ValueError , graph . setVertex , <NUM_LIT:11> , numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:2> ] ) ) <EOL> self . assertRaises ( ValueError , graph . setVertex , <NUM_LIT:2> , numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:8> ] ) ) <EOL> self . assertRaises ( ValueError , graph . setVertex , <NUM_LIT:2> , numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:5> ] ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:1> ) == numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:2> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:0> ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) . all ( ) ) <EOL> def testSetVertex ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . setVertex ( <NUM_LIT:1> , numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:2> ] ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:1> ) == numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:2> ] ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:0> ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) . all ( ) ) <EOL> graph . setVertex ( <NUM_LIT:1> , numpy . array ( [ <NUM_LIT:8> , <NUM_LIT:3> , <NUM_LIT:1> ] ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:1> ) == numpy . array ( [ <NUM_LIT:8> , <NUM_LIT:3> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> def testIsUndirected ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> self . assertEquals ( graph . isUndirected ( ) , True ) <EOL> graph = self . GraphType ( vList , False ) <EOL> self . assertEquals ( graph . isUndirected ( ) , False ) <EOL> def testGetAllVertexIds ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> self . assertTrue ( ( graph . getAllVertexIds ( ) == numpy . array ( list ( range ( <NUM_LIT:0> , numVertices ) ) ) ) . all ( ) ) <EOL> def testSubgraph ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vertices = numpy . random . rand ( numVertices , numFeatures ) <EOL> vList . setVertices ( vertices ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:6> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:9> ) <EOL> subgraph = graph . subgraph ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> self . assertEquals ( subgraph . getNumVertices ( ) , <NUM_LIT:4> ) <EOL> self . assertEquals ( subgraph . getVertexList ( ) . getNumFeatures ( ) , numFeatures ) <EOL> self . assertTrue ( ( subgraph . getVertexList ( ) . getVertices ( list ( range ( <NUM_LIT:0> , <NUM_LIT:4> ) ) ) == vertices [ list ( range ( <NUM_LIT:0> , <NUM_LIT:4> ) ) , : ] ) . all ( ) ) <EOL> self . assertEquals ( subgraph . getNumEdges ( ) , <NUM_LIT:4> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) == <NUM_LIT:1> ) <EOL> subgraph = graph . subgraph ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:6> ] ) <EOL> self . assertEquals ( subgraph . getNumVertices ( ) , <NUM_LIT:4> ) <EOL> self . assertEquals ( subgraph . getVertexList ( ) . getNumFeatures ( ) , numFeatures ) <EOL> self . assertEquals ( subgraph . getNumEdges ( ) , <NUM_LIT:3> ) <EOL> self . assertTrue ( ( subgraph . getVertexList ( ) . getVertices ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) == vertices [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:6> ] , : ] ) . all ( ) ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) == <NUM_LIT:1> ) <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vertices = numpy . random . rand ( numVertices , numFeatures ) <EOL> vList . setVertices ( vertices ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:6> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:9> ) <EOL> subgraph = graph . subgraph ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> self . assertEquals ( subgraph . isUndirected ( ) , False ) <EOL> self . assertEquals ( subgraph . getNumVertices ( ) , <NUM_LIT:4> ) <EOL> self . assertEquals ( subgraph . getVertexList ( ) . getNumFeatures ( ) , numFeatures ) <EOL> self . assertTrue ( ( subgraph . getVertexList ( ) . getVertices ( list ( range ( <NUM_LIT:0> , <NUM_LIT:4> ) ) ) == vertices [ list ( range ( <NUM_LIT:0> , <NUM_LIT:4> ) ) , : ] ) . all ( ) ) <EOL> self . assertEquals ( subgraph . getNumEdges ( ) , <NUM_LIT:4> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) == <NUM_LIT:1> ) <EOL> subgraph = graph . subgraph ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:6> ] ) <EOL> self . assertEquals ( subgraph . getNumVertices ( ) , <NUM_LIT:4> ) <EOL> self . assertEquals ( subgraph . getVertexList ( ) . getNumFeatures ( ) , numFeatures ) <EOL> self . assertEquals ( subgraph . getNumEdges ( ) , <NUM_LIT:3> ) <EOL> self . assertTrue ( ( subgraph . getVertexList ( ) . getVertices ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) == vertices [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:6> ] , : ] ) . all ( ) ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:1> , <NUM_LIT:0> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( subgraph . getEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) == <NUM_LIT:1> ) <EOL> subgraph = graph . subgraph ( [ ] ) <EOL> def testAdd ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph2 = self . GraphType ( vList , False ) <EOL> graph2 . addEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> ) <EOL> graph2 . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> graph2 . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> newGraph = graph . add ( graph2 ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , <NUM_LIT:2> ) <EOL> vList2 = VertexList ( numVertices - <NUM_LIT:1> , numFeatures ) <EOL> graph2 = self . GraphType ( vList2 , False ) <EOL> graph2 . addEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertRaises ( ValueError , graph . add , graph2 ) <EOL> def testMultiply ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph2 = self . GraphType ( vList , False ) <EOL> graph2 . addEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> ) <EOL> graph2 . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> graph2 . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> newGraph = graph . multiply ( graph2 ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( newGraph . getNumEdges ( ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , None ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , None ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) , None ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , <NUM_LIT:6> ) <EOL> vList2 = VertexList ( numVertices - <NUM_LIT:1> , numFeatures ) <EOL> graph2 = self . GraphType ( vList2 , False ) <EOL> graph2 . addEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertRaises ( ValueError , graph . multiply , graph2 ) <EOL> def testCopy ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph2 = graph . copy ( ) <EOL> graph2 . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) , None ) <EOL> def testDensity ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> self . assertEquals ( graph . density ( ) , <NUM_LIT:0> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> self . assertEquals ( graph . density ( ) , float ( <NUM_LIT:1> ) / <NUM_LIT:20> ) <EOL> graph = self . GraphType ( vList , True ) <EOL> self . assertEquals ( graph . density ( ) , <NUM_LIT:0> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> self . assertEquals ( graph . density ( ) , float ( <NUM_LIT:1> ) / <NUM_LIT:10> ) <EOL> def testDepthFirstSearch ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:6> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . depthFirstSearch ( <NUM_LIT:0> ) , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:6> , <NUM_LIT:3> ] ) <EOL> self . assertEquals ( graph . depthFirstSearch ( <NUM_LIT:1> ) , [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:6> , <NUM_LIT:3> ] ) <EOL> self . assertEquals ( graph . depthFirstSearch ( <NUM_LIT:6> ) , [ <NUM_LIT:6> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:3> ] ) <EOL> self . assertEquals ( graph . depthFirstSearch ( <NUM_LIT:4> ) , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> self . assertEquals ( graph . depthFirstSearch ( <NUM_LIT:5> ) , [ <NUM_LIT:5> , <NUM_LIT:4> ] ) <EOL> self . assertEquals ( graph . depthFirstSearch ( <NUM_LIT:7> ) , [ <NUM_LIT:7> ] ) <EOL> def testBreadthFirstSearch ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:7> ) <EOL> graph . addEdge ( <NUM_LIT:7> , <NUM_LIT:8> ) <EOL> graph . addEdge ( <NUM_LIT:7> , <NUM_LIT:9> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:6> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . breadthFirstSearch ( <NUM_LIT:0> ) , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:6> ] ) <EOL> self . assertEquals ( graph . breadthFirstSearch ( <NUM_LIT:1> ) , [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:7> , <NUM_LIT:6> , <NUM_LIT:8> , <NUM_LIT:9> ] ) <EOL> self . assertEquals ( graph . breadthFirstSearch ( <NUM_LIT:6> ) , [ <NUM_LIT:6> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] ) <EOL> self . assertEquals ( graph . breadthFirstSearch ( <NUM_LIT:4> ) , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> self . assertEquals ( graph . breadthFirstSearch ( <NUM_LIT:5> ) , [ <NUM_LIT:5> , <NUM_LIT:4> ] ) <EOL> self . assertEquals ( graph . breadthFirstSearch ( <NUM_LIT:7> ) , [ <NUM_LIT:7> , <NUM_LIT:0> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:6> ] ) <EOL> def testDiameter ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:3> ) <EOL> P = graph . floydWarshall ( False ) <EOL> self . assertEquals ( graph . diameter ( P = P ) , <NUM_LIT:3> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:6> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:3> ) <EOL> P = graph . floydWarshall ( False ) <EOL> self . assertEquals ( graph . diameter ( P = P ) , <NUM_LIT:3> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:0> ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT> ) <EOL> self . assertAlmostEqual ( graph . diameter ( True ) , <NUM_LIT> , places = <NUM_LIT:7> ) <EOL> P = graph . floydWarshall ( True ) <EOL> self . assertAlmostEquals ( graph . diameter ( True , P = P ) , <NUM_LIT> , places = <NUM_LIT:7> ) <EOL> def testEffectiveDiameter ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . diameter ( ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> ) , <NUM_LIT:2> ) <EOL> P = graph . floydWarshall ( False ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> , P = P ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> , P = P ) , <NUM_LIT:2> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:6> ) <EOL> graph . addEdge ( <NUM_LIT:7> , <NUM_LIT:8> ) <EOL> graph . addEdge ( <NUM_LIT:8> , <NUM_LIT:9> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> ) , <NUM_LIT:1> ) <EOL> P = graph . floydWarshall ( False ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> , P = P ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT> , P = P ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> , P = P ) , <NUM_LIT:1> ) <EOL> graph = self . GraphType ( vList , True ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.1> ) , <NUM_LIT:0> ) <EOL> P = graph . floydWarshall ( False ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.1> , P = P ) , <NUM_LIT:0> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.1> ) , <NUM_LIT:0> ) <EOL> P = graph . floydWarshall ( False ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.1> , P = P ) , <NUM_LIT:0> ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.1> ) , <NUM_LIT:0> ) <EOL> P = graph . floydWarshall ( False ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:1.0> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.5> , P = P ) , <NUM_LIT:0> ) <EOL> self . assertEquals ( graph . effectiveDiameter ( <NUM_LIT:0.1> , P = P ) , <NUM_LIT:0> ) <EOL> def testFindComponents ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:6> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . findConnectedComponents ( ) [ <NUM_LIT:0> ] , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:6> ] ) <EOL> self . assertEquals ( graph . findConnectedComponents ( ) [ <NUM_LIT:1> ] , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> graph = self . GraphType ( vList , False ) <EOL> self . assertRaises ( ValueError , graph . findConnectedComponents ) <EOL> def testFitPowerLaw ( self ) : <EOL> numVertices = <NUM_LIT:1000> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> ell = <NUM_LIT:2> <EOL> m = <NUM_LIT:2> <EOL> generator = BarabasiAlbertGenerator ( ell , m ) <EOL> graph = generator . generate ( graph ) <EOL> alpha , ks , xmin = graph . fitPowerLaw ( ) <EOL> self . assertAlmostEquals ( alpha , <NUM_LIT> , places = <NUM_LIT:0> ) <EOL> def testFloydWarshall ( self ) : <EOL> P = self . graph . floydWarshall ( ) <EOL> P2 = numpy . zeros ( ( self . numVertices , self . numVertices ) ) <EOL> P2 [ <NUM_LIT:0> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:1> , : ] = numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:2> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:2> , : ] = numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:3> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:3> , : ] = numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:1> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:4> , : ] = numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:0> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:5> , : ] = numpy . array ( [ numpy . inf , numpy . inf , numpy . inf , numpy . inf , numpy . inf , <NUM_LIT:0> ] ) <EOL> self . assertTrue ( ( P == P2 ) . all ( ) ) <EOL> P = self . graph2 . floydWarshall ( ) <EOL> P2 = numpy . zeros ( ( self . numVertices , self . numVertices ) ) <EOL> P2 [ <NUM_LIT:0> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:1> , : ] = numpy . array ( [ numpy . inf , <NUM_LIT:0> , numpy . inf , <NUM_LIT:1> , <NUM_LIT:2> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:2> , : ] = numpy . array ( [ numpy . inf , numpy . inf , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:6> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:3> , : ] = numpy . array ( [ numpy . inf , numpy . inf , numpy . inf , <NUM_LIT:0> , <NUM_LIT:1> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:4> , : ] = numpy . array ( [ numpy . inf , numpy . inf , numpy . inf , numpy . inf , <NUM_LIT:0> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:5> , : ] = numpy . array ( [ numpy . inf , numpy . inf , numpy . inf , numpy . inf , numpy . inf , <NUM_LIT:0> ] ) <EOL> self . assertTrue ( ( P == P2 ) . all ( ) ) <EOL> def testFindAllDistances ( self ) : <EOL> P = self . graph . findAllDistances ( ) <EOL> P2 = numpy . zeros ( ( self . numVertices , self . numVertices ) ) <EOL> P2 [ <NUM_LIT:0> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:1> , : ] = numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:2> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:2> , : ] = numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:3> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:3> , : ] = numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:1> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:4> , : ] = numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:0> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:5> , : ] = numpy . array ( [ numpy . inf , numpy . inf , numpy . inf , numpy . inf , numpy . inf , <NUM_LIT:0> ] ) <EOL> self . assertTrue ( ( P == P2 ) . all ( ) ) <EOL> P = self . graph2 . findAllDistances ( ) <EOL> P2 = numpy . zeros ( ( self . numVertices , self . numVertices ) ) <EOL> P2 [ <NUM_LIT:0> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:1> , : ] = numpy . array ( [ numpy . inf , <NUM_LIT:0> , numpy . inf , <NUM_LIT:1> , <NUM_LIT:2> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:2> , : ] = numpy . array ( [ numpy . inf , numpy . inf , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:6> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:3> , : ] = numpy . array ( [ numpy . inf , numpy . inf , numpy . inf , <NUM_LIT:0> , <NUM_LIT:1> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:4> , : ] = numpy . array ( [ numpy . inf , numpy . inf , numpy . inf , numpy . inf , <NUM_LIT:0> , numpy . inf ] ) <EOL> P2 [ <NUM_LIT:5> , : ] = numpy . array ( [ numpy . inf , numpy . inf , numpy . inf , numpy . inf , numpy . inf , <NUM_LIT:0> ] ) <EOL> self . assertTrue ( ( P == P2 ) . all ( ) ) <EOL> def testEgoGraph ( self ) : <EOL> numVertices = <NUM_LIT:6> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> egoGraph = graph . egoGraph ( <NUM_LIT:0> ) <EOL> self . assertTrue ( egoGraph . getNumVertices ( ) == <NUM_LIT:4> ) <EOL> self . assertTrue ( egoGraph . getNumEdges ( ) == <NUM_LIT:5> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> egoGraph = graph . egoGraph ( <NUM_LIT:4> ) <EOL> self . assertTrue ( egoGraph . getNumVertices ( ) == <NUM_LIT:2> ) <EOL> self . assertTrue ( egoGraph . getNumEdges ( ) == <NUM_LIT:1> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:1> , <NUM_LIT:0> ) , <NUM_LIT:1> ) <EOL> egoGraph = graph . egoGraph ( <NUM_LIT:3> ) <EOL> self . assertTrue ( egoGraph . getNumVertices ( ) == <NUM_LIT:3> ) <EOL> self . assertTrue ( egoGraph . getNumEdges ( ) == <NUM_LIT:3> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( egoGraph . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> egoGraph = graph . egoGraph ( <NUM_LIT:5> ) <EOL> self . assertTrue ( egoGraph . getNumVertices ( ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( egoGraph . getNumEdges ( ) == <NUM_LIT:0> ) <EOL> def testStr ( self ) : <EOL> logging . debug ( ( self . graph ) ) <EOL> def testRemoveAllEdges ( self ) : <EOL> numVertices = <NUM_LIT:6> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:6> ) <EOL> graph . removeAllEdges ( ) <EOL> self . assertTrue ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) == None ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:0> ) <EOL> def testAdjacencyMatrix ( self ) : <EOL> numVertices = <NUM_LIT:3> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> A = graph . adjacencyMatrix ( ) <EOL> W = graph . getWeightMatrix ( ) <EOL> W2 = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> A2 = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> W2 [ <NUM_LIT:0> , <NUM_LIT:1> ] = <NUM_LIT:0.5> <EOL> W2 [ <NUM_LIT:2> , <NUM_LIT:1> ] = <NUM_LIT> <EOL> W2 [ <NUM_LIT:1> , <NUM_LIT:1> ] = <NUM_LIT:0.1> <EOL> A2 [ <NUM_LIT:0> , <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> A2 [ <NUM_LIT:2> , <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> A2 [ <NUM_LIT:1> , <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> self . assertTrue ( ( W == W2 ) . all ( ) ) <EOL> self . assertTrue ( ( A == A2 ) . all ( ) ) <EOL> def testComplement ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph3 = graph . complement ( ) <EOL> self . assertTrue ( graph3 . isUndirected ( ) ) <EOL> self . assertEquals ( graph3 . getNumEdges ( ) , ( numVertices ** <NUM_LIT:2> + numVertices ) / <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT> ) <EOL> graph2 = graph . complement ( ) <EOL> self . assertTrue ( graph2 . isUndirected ( ) ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:4> , <NUM_LIT:2> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:6> , <NUM_LIT:7> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:3> , <NUM_LIT:3> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:0> , <NUM_LIT:0> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph2 . getNumEdges ( ) , <NUM_LIT:50> ) <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph3 = graph . complement ( ) <EOL> self . assertEquals ( graph3 . getNumEdges ( ) , numVertices ** <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT> ) <EOL> graph2 = graph . complement ( ) <EOL> self . assertFalse ( graph2 . isUndirected ( ) ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:4> , <NUM_LIT:2> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:6> , <NUM_LIT:7> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:3> , <NUM_LIT:3> ) , None ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:0> , <NUM_LIT:0> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph2 . getEdge ( <NUM_LIT:1> , <NUM_LIT:0> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph2 . getNumEdges ( ) , <NUM_LIT> ) <EOL> def testFindTrees ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:1> ) <EOL> trees = graph . findTrees ( ) <EOL> self . assertEquals ( trees [ <NUM_LIT:0> ] , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> self . assertEquals ( trees [ <NUM_LIT:1> ] , [ <NUM_LIT:6> , <NUM_LIT:7> ] ) <EOL> self . assertEquals ( trees [ <NUM_LIT:2> ] , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> self . assertEquals ( trees [ <NUM_LIT:3> ] , [ <NUM_LIT:9> ] ) <EOL> self . assertEquals ( trees [ <NUM_LIT:4> ] , [ <NUM_LIT:8> ] ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:8> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:1> ) <EOL> trees = graph . findTrees ( ) <EOL> self . assertEquals ( set ( trees [ <NUM_LIT:0> ] ) , set ( [ <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] ) ) <EOL> self . assertEquals ( trees [ <NUM_LIT:1> ] , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> self . assertEquals ( trees [ <NUM_LIT:2> ] , [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> self . assertEquals ( trees [ <NUM_LIT:3> ] , [ <NUM_LIT:0> ] ) <EOL> numVertices = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> trees = graph . findTrees ( ) <EOL> self . assertEquals ( [ len ( x ) for x in trees ] , [ <NUM_LIT:1> ] ) <EOL> def testSetWeightMatrix ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vList . setVertices ( numpy . random . rand ( numVertices , numFeatures ) ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> W = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> W [ <NUM_LIT:1> , <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> W [ <NUM_LIT:2> , <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> W [ <NUM_LIT:1> , <NUM_LIT:2> ] = <NUM_LIT:1> <EOL> graph . setWeightMatrix ( W ) <EOL> self . assertTrue ( ( graph . getAllEdges ( ) == numpy . array ( [ [ <NUM_LIT:1> , <NUM_LIT:1> ] , [ <NUM_LIT:2> , <NUM_LIT:1> ] ] ) ) . all ( ) ) <EOL> W [ <NUM_LIT:1> , <NUM_LIT:3> ] = <NUM_LIT:1> <EOL> self . assertRaises ( ValueError , graph . setWeightMatrix , W ) <EOL> W = numpy . zeros ( ( numVertices , numVertices + <NUM_LIT:1> ) ) <EOL> self . assertRaises ( ValueError , graph . setWeightMatrix , W ) <EOL> graph = self . GraphType ( vList , False ) <EOL> W = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> W [ <NUM_LIT:1> , <NUM_LIT:0> ] = <NUM_LIT:1> <EOL> W [ <NUM_LIT:3> , <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> W [ <NUM_LIT:1> , <NUM_LIT:3> ] = <NUM_LIT:1> <EOL> graph . setWeightMatrix ( W ) <EOL> self . assertTrue ( ( graph . getAllEdges ( ) == numpy . array ( [ [ <NUM_LIT:1> , <NUM_LIT:0> ] , [ <NUM_LIT:1> , <NUM_LIT:3> ] , [ <NUM_LIT:3> , <NUM_LIT:1> ] ] ) ) . all ( ) ) <EOL> def testGetNumDirEdges ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> self . assertTrue ( graph . getNumDirEdges ( ) == <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getNumDirEdges ( ) == <NUM_LIT:5> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> self . assertTrue ( graph . getNumDirEdges ( ) == <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getNumDirEdges ( ) == <NUM_LIT:3> ) <EOL> def testOutDegreeSequence ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> self . assertTrue ( ( graph . outDegreeSequence ( ) == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) . all ( ) ) <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> self . assertTrue ( ( graph . outDegreeSequence ( ) == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) . all ( ) ) <EOL> def testInDegreeSequence ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> self . assertTrue ( ( graph . inDegreeSequence ( ) == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) . all ( ) ) <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> self . assertTrue ( ( graph . inDegreeSequence ( ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) . all ( ) ) <EOL> def testInDegreeDistribution ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> self . assertTrue ( ( graph . inDegreeDistribution ( ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . inDegreeDistribution ( ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> self . assertTrue ( ( graph . inDegreeDistribution ( ) == numpy . array ( [ <NUM_LIT:5> ] ) ) . all ( ) ) <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . inDegreeDistribution ( ) == numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> self . assertTrue ( ( graph . inDegreeDistribution ( ) == numpy . array ( [ ] ) ) . all ( ) ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> self . assertTrue ( ( graph . inDegreeDistribution ( ) == numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> ] ) ) . all ( ) ) <EOL> def testGeneralVertexList ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> vList = GeneralVertexList ( numVertices ) <EOL> vList . setVertex ( <NUM_LIT:0> , "<STR_LIT:a>" ) <EOL> vList . setVertex ( <NUM_LIT:1> , "<STR_LIT:b>" ) <EOL> vList . setVertex ( <NUM_LIT:5> , "<STR_LIT:c>" ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> def testFromNetworkXGraph ( self ) : <EOL> try : <EOL> import networkx <EOL> except ImportError as error : <EOL> logging . debug ( error ) <EOL> return <EOL> nxGraph = networkx . Graph ( ) <EOL> nxGraph . graph [ "<STR_LIT>" ] = GeneralVertexList <EOL> nxGraph . add_edge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> nxGraph . add_edge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> nxGraph . add_edge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> graph = self . GraphType . fromNetworkXGraph ( nxGraph ) <EOL> self . assertTrue ( graph . getNumVertices ( ) == <NUM_LIT:4> ) <EOL> self . assertTrue ( graph . isUndirected ( ) == True ) <EOL> self . assertTrue ( graph . getNumEdges ( ) == <NUM_LIT:3> ) <EOL> self . assertTrue ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) == <NUM_LIT:1> ) <EOL> nxGraph = networkx . DiGraph ( ) <EOL> nxGraph . graph [ "<STR_LIT>" ] = GeneralVertexList <EOL> nxGraph . add_edge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> nxGraph . add_edge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> nxGraph . add_edge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> graph = self . GraphType . fromNetworkXGraph ( nxGraph ) <EOL> self . assertTrue ( graph . getNumVertices ( ) == <NUM_LIT:4> ) <EOL> self . assertTrue ( graph . isUndirected ( ) == False ) <EOL> self . assertTrue ( graph . getNumEdges ( ) == <NUM_LIT:3> ) <EOL> self . assertTrue ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) == <NUM_LIT:1> ) <EOL> nxGraph = networkx . MultiGraph ( ) <EOL> self . assertRaises ( ValueError , self . GraphType . fromNetworkXGraph , nxGraph ) <EOL> nxGraph = networkx . DiGraph ( ) <EOL> nxGraph . graph [ "<STR_LIT>" ] = GeneralVertexList <EOL> nxGraph . add_node ( "<STR_LIT:a>" , label = "<STR_LIT:abc>" ) <EOL> nxGraph . add_node ( "<STR_LIT:b>" , label = "<STR_LIT:i>" ) <EOL> nxGraph . add_node ( "<STR_LIT:c>" , label = "<STR_LIT>" ) <EOL> nxGraph . add_node ( "<STR_LIT:d>" , label = "<STR_LIT>" ) <EOL> nxGraph . add_edge ( "<STR_LIT:a>" , "<STR_LIT:b>" ) <EOL> nxGraph . add_edge ( "<STR_LIT:b>" , "<STR_LIT:c>" ) <EOL> nxGraph . add_edge ( "<STR_LIT:b>" , "<STR_LIT:d>" ) <EOL> graph = self . GraphType . fromNetworkXGraph ( nxGraph ) <EOL> nodeDict = { } <EOL> for i in range ( len ( nxGraph . nodes ( ) ) ) : <EOL> nodeDict [ nxGraph . nodes ( ) [ i ] ] = i <EOL> self . assertTrue ( graph . getNumVertices ( ) == <NUM_LIT:4> ) <EOL> self . assertTrue ( graph . isUndirected ( ) == False ) <EOL> self . assertTrue ( graph . getNumEdges ( ) == <NUM_LIT:3> ) <EOL> self . assertTrue ( graph . getEdge ( nodeDict [ "<STR_LIT:a>" ] , nodeDict [ "<STR_LIT:b>" ] ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getEdge ( nodeDict [ "<STR_LIT:b>" ] , nodeDict [ "<STR_LIT:c>" ] ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getEdge ( nodeDict [ "<STR_LIT:b>" ] , nodeDict [ "<STR_LIT:d>" ] ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( graph . getVertex ( <NUM_LIT:0> ) == "<STR_LIT:abc>" ) <EOL> self . assertTrue ( graph . getVertex ( <NUM_LIT:1> ) == "<STR_LIT>" ) <EOL> self . assertTrue ( graph . getVertex ( <NUM_LIT:2> ) == "<STR_LIT:i>" ) <EOL> self . assertTrue ( graph . getVertex ( <NUM_LIT:3> ) == "<STR_LIT>" ) <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:2> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vList . setVertices ( numpy . random . rand ( numVertices , numFeatures ) ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> nxGraph = graph . toNetworkXGraph ( ) <EOL> graph2 = self . GraphType . fromNetworkXGraph ( nxGraph ) <EOL> tol = <NUM_LIT:10> ** - <NUM_LIT:6> <EOL> self . assertTrue ( numpy . linalg . norm ( graph . getVertexList ( ) . getVertices ( list ( range ( numVertices ) ) ) - graph2 . getVertexList ( ) . getVertices ( list ( range ( numVertices ) ) ) ) < tol ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , graph2 . getNumEdges ( ) ) <EOL> for i in range ( numVertices ) : <EOL> for j in range ( numVertices ) : <EOL> self . assertEquals ( graph . getEdge ( i , j ) , graph2 . getEdge ( i , j ) ) <EOL> numVertices = <NUM_LIT:10> <EOL> vList = GeneralVertexList ( numVertices ) <EOL> for i in range ( numVertices ) : <EOL> vList . setVertex ( i , "<STR_LIT:s>" + str ( i ) ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> nxGraph = graph . toNetworkXGraph ( ) <EOL> graph2 = self . GraphType . fromNetworkXGraph ( nxGraph ) <EOL> for i in range ( numVertices ) : <EOL> self . assertEquals ( graph . getVertex ( i ) , graph2 . getVertex ( i ) ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , graph2 . getNumEdges ( ) ) <EOL> for i in range ( numVertices ) : <EOL> for j in range ( numVertices ) : <EOL> self . assertEquals ( graph . getEdge ( i , j ) , graph2 . getEdge ( i , j ) ) <EOL> def testDiameter2 ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:3> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:5> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:6> ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:3> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> self . assertEquals ( graph . diameter2 ( ) , <NUM_LIT:0> ) <EOL> def testLaplacianMatrix ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> L = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> A = graph . adjacencyMatrix ( ) <EOL> for i in range ( numVertices ) : <EOL> for j in range ( numVertices ) : <EOL> if i == j : <EOL> L [ i , j ] = numpy . sum ( A [ i , : ] ) <EOL> elif A [ i , j ] != <NUM_LIT:0> : <EOL> L [ i , j ] = - <NUM_LIT:1> <EOL> else : <EOL> L [ i , j ] = <NUM_LIT:0> <EOL> self . assertTrue ( ( L == graph . laplacianMatrix ( ) ) . all ( ) ) <EOL> def testLoad ( self ) : <EOL> try : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vList . setVertices ( numpy . random . rand ( numVertices , numFeatures ) ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT> ) <EOL> tempDir = PathDefaults . getTempDir ( ) <EOL> tempFile = tempDir + "<STR_LIT>" <EOL> graph . save ( tempFile ) <EOL> dataDir = PathDefaults . getDataDir ( ) <EOL> os . chdir ( dataDir ) <EOL> currentPath = os . getcwd ( ) <EOL> graph2 = self . GraphType . load ( tempFile ) <EOL> self . assertEquals ( os . getcwd ( ) , currentPath ) <EOL> self . assertEquals ( graph . getNumVertices ( ) , graph . getNumVertices ( ) ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , graph . getNumEdges ( ) ) <EOL> self . assertTrue ( graph2 . isUndirected ( ) == True ) <EOL> self . assertTrue ( ( graph . getVertexList ( ) . getVertices ( list ( range ( numVertices ) ) ) == graph2 . getVertexList ( ) . getVertices ( list ( range ( numVertices ) ) ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . getAllEdges ( ) == graph2 . getAllEdges ( ) ) . all ( ) ) <EOL> self . assertTrue ( graph2 . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) == <NUM_LIT:0.1> ) <EOL> self . assertTrue ( graph2 . getEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) == <NUM_LIT> ) <EOL> self . assertTrue ( graph2 . getEdge ( <NUM_LIT:1> , <NUM_LIT:3> ) == <NUM_LIT> ) <EOL> testDir = PathDefaults . getDataDir ( ) + "<STR_LIT>" <EOL> graphFilename = testDir + "<STR_LIT>" <EOL> graph = self . GraphType . load ( graphFilename ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:1> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:2> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumVertices ( ) , <NUM_LIT:10> ) <EOL> except IOError as e : <EOL> logging . warn ( e ) <EOL> pass <EOL> except OSError as e : <EOL> logging . warn ( e ) <EOL> pass <EOL> def testMaxEigenvector ( self ) : <EOL> tol = <NUM_LIT:10> ** - <NUM_LIT:6> <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:0> ) <EOL> v = graph . maxEigenvector ( ) <EOL> W = graph . getWeightMatrix ( ) <EOL> lmbda , U = numpy . linalg . eig ( W ) <EOL> i = numpy . argmax ( lmbda ) <EOL> self . assertTrue ( numpy . linalg . norm ( U [ : , i ] - v ) < tol ) <EOL> def testMaxProductPaths ( self ) : <EOL> numVertices = <NUM_LIT:6> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> P = graph . maxProductPaths ( ) <EOL> P2 = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> P2 [ <NUM_LIT:0> , : ] = numpy . array ( [ <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0.1> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:1> , : ] = numpy . array ( [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:2> , : ] = numpy . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:3> , : ] = numpy . array ( [ <NUM_LIT:0.1> , <NUM_LIT:0.1> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:4> , : ] = numpy . array ( [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:5> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> self . assertAlmostEquals ( numpy . linalg . norm ( P - P2 ) , <NUM_LIT:0> , places = <NUM_LIT:6> ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> P = graph . maxProductPaths ( ) <EOL> P2 = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> P2 [ <NUM_LIT:0> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0.1> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:1> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:2> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:3> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0.1> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:4> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> P2 [ <NUM_LIT:5> , : ] = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> self . assertAlmostEquals ( numpy . linalg . norm ( P - P2 ) , <NUM_LIT:0> , places = <NUM_LIT:6> ) <EOL> def testMaybeIsomorphicWith ( self ) : <EOL> numVertices = <NUM_LIT:6> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> graph2 = self . GraphType ( vList , True ) <EOL> graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph2 . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:0.5> ) <EOL> graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:0.1> ) <EOL> graph3 = self . GraphType ( vList , True ) <EOL> graph3 . addEdge ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> graph3 . addEdge ( <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:0.1> ) <EOL> graph3 . addEdge ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> ) <EOL> graph3 . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:0.5> ) <EOL> graph3 . addEdge ( <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0.1> ) <EOL> graph3 . addEdge ( <NUM_LIT:5> , <NUM_LIT:0> , <NUM_LIT:0.1> ) <EOL> self . assertTrue ( graph . maybeIsomorphicWith ( graph ) ) <EOL> self . assertFalse ( graph . maybeIsomorphicWith ( graph2 ) ) <EOL> self . assertTrue ( graph . maybeIsomorphicWith ( graph3 ) ) <EOL> def testSave ( self ) : <EOL> try : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vList . setVertices ( numpy . random . rand ( numVertices , numFeatures ) ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT> ) <EOL> dataDir = PathDefaults . getDataDir ( ) <EOL> os . chdir ( dataDir ) <EOL> tempDir = PathDefaults . getTempDir ( ) <EOL> currentPath = os . getcwd ( ) <EOL> graph . save ( tempDir + "<STR_LIT>" ) <EOL> self . assertEquals ( os . getcwd ( ) , currentPath ) <EOL> except IOError as e : <EOL> logging . warn ( e ) <EOL> pass <EOL> except OSError as e : <EOL> logging . warn ( e ) <EOL> pass <EOL> def testSetVertices ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vList . setVertices ( numpy . random . rand ( numVertices , numFeatures ) ) <EOL> graph = self . GraphType ( vList , False ) <EOL> X = numpy . random . rand ( numVertices , numFeatures ) <EOL> vertexIndices = list ( range ( <NUM_LIT:0> , numVertices ) ) <EOL> graph . setVertices ( vertexIndices , X ) <EOL> vertexIndices2 = graph . getAllVertexIds ( ) <EOL> vertices2 = graph . getVertices ( vertexIndices2 ) <EOL> self . assertEquals ( vertexIndices , vertexIndices2 ) <EOL> self . assertTrue ( ( X == vertices2 ) . all ( ) ) <EOL> def testToNetworkXGraph ( self ) : <EOL> try : <EOL> import networkx <EOL> except ImportError as error : <EOL> logging . debug ( error ) <EOL> return <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:9> , <NUM_LIT:6> ) <EOL> graph2 = self . GraphType ( vList , False ) <EOL> graph2 . addEdge ( <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:4> ) <EOL> graph2 . addEdge ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> graph2 . addEdge ( <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:4> ) <EOL> graph2 . addEdge ( <NUM_LIT:1> , <NUM_LIT:9> , <NUM_LIT:6> ) <EOL> networkXGraph = graph . toNetworkXGraph ( ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:5> , <NUM_LIT:1> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:5> , <NUM_LIT:2> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:2> , <NUM_LIT:7> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:1> , <NUM_LIT:9> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:9> , <NUM_LIT:1> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> vertexIndexList = [ ] <EOL> for i in networkXGraph . __iter__ ( ) : <EOL> vertexIndexList . append ( i ) <EOL> vertexIndexList . sort ( ) <EOL> self . assertTrue ( vertexIndexList == list ( range ( numVertices ) ) ) <EOL> self . assertTrue ( networkXGraph . edges ( ) == [ ( <NUM_LIT:1> , <NUM_LIT:9> ) , ( <NUM_LIT:1> , <NUM_LIT:5> ) , ( <NUM_LIT:2> , <NUM_LIT:5> ) , ( <NUM_LIT:2> , <NUM_LIT:7> ) ] ) <EOL> self . assertTrue ( type ( networkXGraph ) == networkx . Graph ) <EOL> networkXGraph = graph2 . toNetworkXGraph ( ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:5> , <NUM_LIT:1> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:5> , <NUM_LIT:2> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:2> , <NUM_LIT:7> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> self . assertEquals ( networkXGraph . get_edge_data ( <NUM_LIT:1> , <NUM_LIT:9> ) , { '<STR_LIT:value>' : <NUM_LIT> } ) <EOL> self . assertFalse ( networkXGraph . has_edge ( <NUM_LIT:9> , <NUM_LIT:1> ) ) <EOL> vertexIndexList = [ ] <EOL> for i in networkXGraph . __iter__ ( ) : <EOL> vertexIndexList . append ( i ) <EOL> vertexIndexList . sort ( ) <EOL> self . assertTrue ( vertexIndexList == list ( range ( numVertices ) ) ) <EOL> self . assertTrue ( networkXGraph . edges ( ) == [ ( <NUM_LIT:1> , <NUM_LIT:9> ) , ( <NUM_LIT:2> , <NUM_LIT:7> ) , ( <NUM_LIT:5> , <NUM_LIT:1> ) , ( <NUM_LIT:5> , <NUM_LIT:2> ) ] ) <EOL> self . assertTrue ( type ( networkXGraph ) == networkx . DiGraph ) <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:3> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vList . setVertices ( numpy . random . rand ( numVertices , numFeatures ) ) <EOL> graph = self . GraphType ( vList ) <EOL> networkXGraph = graph . toNetworkXGraph ( ) <EOL> self . assertTrue ( networkXGraph . order ( ) == numVertices ) <EOL> self . assertTrue ( networkXGraph . size ( ) == <NUM_LIT:0> ) <EOL> self . assertTrue ( ( networkXGraph . nodes ( data = True ) [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] [ '<STR_LIT:label>' ] == graph . getVertex ( <NUM_LIT:0> ) ) . all ( ) ) <EOL> def testTriangleSequence ( self ) : <EOL> tol = <NUM_LIT:10> ** - <NUM_LIT:6> <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> seq = graph . triangleSequence ( ) <EOL> self . assertTrue ( numpy . linalg . norm ( seq - numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) < tol ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> seq = graph . triangleSequence ( ) <EOL> self . assertTrue ( numpy . linalg . norm ( seq - numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) < tol ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:0> , - <NUM_LIT> ) <EOL> seq = graph . triangleSequence ( ) <EOL> self . assertTrue ( numpy . linalg . norm ( seq - numpy . array ( [ <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:0> ] ) ) < tol ) <EOL> graph . removeAllEdges ( ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> seq = graph . triangleSequence ( ) <EOL> self . assertTrue ( numpy . linalg . norm ( seq - numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) < tol ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:0> ) <EOL> seq = graph . triangleSequence ( ) <EOL> self . assertTrue ( numpy . linalg . norm ( seq - numpy . array ( [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) < tol ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:0> ) <EOL> seq = graph . triangleSequence ( ) <EOL> self . assertTrue ( numpy . linalg . norm ( seq - numpy . array ( [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) ) < tol ) <EOL> def testUnion ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:0.1> ) <EOL> graph2 = self . GraphType ( vList , True ) <EOL> graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:5> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> newGraph = graph . union ( graph2 ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:6> , <NUM_LIT:0> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( newGraph . getNumEdges ( ) , <NUM_LIT:5> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:6> , <NUM_LIT:0> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:5> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> newGraph = graph2 . union ( graph2 ) <EOL> self . assertEquals ( newGraph . getNumEdges ( ) , <NUM_LIT:3> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:5> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> def testIntersect ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:0.1> ) <EOL> graph2 = self . GraphType ( vList , True ) <EOL> graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:5> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> newGraph = graph . intersect ( graph2 ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:6> , <NUM_LIT:0> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( newGraph . getNumEdges ( ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> newGraph = graph2 . intersect ( graph2 ) <EOL> self . assertEquals ( newGraph . getNumEdges ( ) , <NUM_LIT:3> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:5> , <NUM_LIT:3> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> def testIsTree ( self ) : <EOL> numVertices = <NUM_LIT:3> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> self . assertFalse ( graph . isTree ( ) ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> self . assertTrue ( graph . isTree ( ) ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:0> ) <EOL> self . assertFalse ( graph . isTree ( ) ) <EOL> graph = self . GraphType ( vList , True ) <EOL> self . assertRaises ( ValueError , graph . isTree ) <EOL> numVertices = <NUM_LIT:6> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:4> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:5> ) <EOL> self . assertTrue ( graph . isTree ( ) ) <EOL> graph . removeEdge ( <NUM_LIT:0> , <NUM_LIT:5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> self . assertTrue ( graph . isTree ( ) ) <EOL> numVertices = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , False ) <EOL> self . assertTrue ( graph . isTree ( ) ) <EOL> def testBetweenness ( self ) : <EOL> tol = <NUM_LIT:10> ** - <NUM_LIT:6> <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> def testSetVertexList ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> vList . setVertices ( numpy . random . rand ( numVertices , numFeatures ) ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:0> ) == vList . getVertex ( <NUM_LIT:0> ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:1> ) == vList . getVertex ( <NUM_LIT:1> ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:2> ) == vList . getVertex ( <NUM_LIT:2> ) ) . all ( ) ) <EOL> vList2 = VertexList ( numVertices , numFeatures + <NUM_LIT:2> ) <EOL> vList2 . setVertices ( numpy . random . rand ( numVertices , numFeatures + <NUM_LIT:2> ) ) <EOL> graph . setVertexList ( vList2 ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:0> ) == vList2 . getVertex ( <NUM_LIT:0> ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:1> ) == vList2 . getVertex ( <NUM_LIT:1> ) ) . all ( ) ) <EOL> self . assertTrue ( ( graph . getVertex ( <NUM_LIT:2> ) == vList2 . getVertex ( <NUM_LIT:2> ) ) . all ( ) ) <EOL> vList3 = VertexList ( numVertices + <NUM_LIT:1> , numFeatures ) <EOL> self . assertRaises ( ValueError , graph . setVertexList , vList3 ) <EOL> def testNormalisedLaplacianSym ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:9> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> L = graph . normalisedLaplacianSym ( ) <EOL> W = graph . getWeightMatrix ( ) <EOL> L2 = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> d = graph . outDegreeSequence ( ) <EOL> for i in range ( numVertices ) : <EOL> for j in range ( numVertices ) : <EOL> if d [ i ] != <NUM_LIT:0> and d [ j ] != <NUM_LIT:0> : <EOL> Wij = W [ i , j ] / ( numpy . sqrt ( d [ i ] * d [ j ] ) ) <EOL> else : <EOL> Wij = <NUM_LIT:0> <EOL> if i == j : <EOL> L2 [ i , j ] = <NUM_LIT:1> - Wij <EOL> else : <EOL> L2 [ i , j ] = - Wij <EOL> tol = <NUM_LIT:10> ** - <NUM_LIT:6> <EOL> self . assertTrue ( numpy . linalg . norm ( L2 - L ) < tol ) <EOL> def testNormalisedLaplacianRw ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:9> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> L = graph . normalisedLaplacianRw ( ) <EOL> W = graph . getWeightMatrix ( ) <EOL> L2 = numpy . zeros ( ( numVertices , numVertices ) ) <EOL> d = graph . outDegreeSequence ( ) <EOL> for i in range ( numVertices ) : <EOL> for j in range ( numVertices ) : <EOL> if d [ i ] != <NUM_LIT:0> and d [ j ] != <NUM_LIT:0> : <EOL> Wij = W [ i , j ] / ( d [ i ] ) <EOL> else : <EOL> Wij = <NUM_LIT:0> <EOL> if i == j : <EOL> L2 [ i , j ] = <NUM_LIT:1> - Wij <EOL> else : <EOL> L2 [ i , j ] = - Wij <EOL> tol = <NUM_LIT:10> ** - <NUM_LIT:6> <EOL> self . assertTrue ( numpy . linalg . norm ( L2 - L ) < tol ) <EOL> def testSetDiff ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph2 = self . GraphType ( vList , True ) <EOL> graph2 . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:5> , <NUM_LIT:3> , <NUM_LIT:0.1> ) <EOL> graph2 . addEdge ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> newGraph = graph . setDiff ( graph2 ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:5> , <NUM_LIT:2> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:6> , <NUM_LIT:0> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph . getEdge ( <NUM_LIT:6> , <NUM_LIT:1> ) , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( newGraph . getNumEdges ( ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:6> , <NUM_LIT:0> ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph . getEdge ( <NUM_LIT:6> , <NUM_LIT:1> ) , <NUM_LIT:1> ) <EOL> newGraph = graph2 . setDiff ( graph2 ) <EOL> self . assertEquals ( newGraph . getNumEdges ( ) , <NUM_LIT:0> ) <EOL> def testIncidenceMatrix ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> X = graph . incidenceMatrix ( ) . todense ( ) <EOL> L = X . dot ( X . T ) <EOL> L2 = graph . laplacianMatrix ( ) <EOL> self . assertTrue ( ( L == L2 ) . all ( ) ) <EOL> graph = self . GraphType ( vList , False ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> X = graph . incidenceMatrix ( ) . todense ( ) <EOL> L = X . dot ( X . T ) <EOL> L2 = graph . laplacianMatrix ( ) <EOL> def testDegreeSequence ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> self . assertTrue ( ( graph . degreeSequence ( ) == [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) . all ( ) ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . assertTrue ( ( graph . degreeSequence ( ) == [ <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) . all ( ) ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertTrue ( ( graph . degreeSequence ( ) == [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) . all ( ) ) <EOL> def testAdjacencyList ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList , True ) <EOL> graph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT> ) <EOL> graph . addEdge ( <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT> ) <EOL> L , W = graph . adjacencyList ( ) <EOL> for i in range ( numVertices ) : <EOL> self . assertTrue ( ( L [ i ] == numpy . sort ( graph . neighbours ( i ) ) ) . all ( ) ) <EOL> self . assertTrue ( W [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == <NUM_LIT:0.1> ) <EOL> self . assertTrue ( W [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] == <NUM_LIT> ) <EOL> self . assertTrue ( W [ <NUM_LIT:4> ] [ <NUM_LIT:0> ] == <NUM_LIT> ) <EOL> L , W = graph . adjacencyList ( False ) <EOL> for i in range ( numVertices ) : <EOL> self . assertTrue ( ( L [ i ] == numpy . sort ( graph . neighbours ( i ) ) ) . all ( ) ) <EOL> self . assertTrue ( W [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == <NUM_LIT:1> ) <EOL> self . assertTrue ( W [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] == <NUM_LIT:1> ) <EOL> self . assertTrue ( W [ <NUM_LIT:4> ] [ <NUM_LIT:0> ] == <NUM_LIT:1> ) <EOL> def testGetItem ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> graph = self . GraphType ( GeneralVertexList ( numVertices ) ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> graph . addEdge ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> graph . setVertex ( <NUM_LIT:0> , "<STR_LIT:abc>" ) <EOL> self . assertEquals ( graph [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph [ <NUM_LIT:1> , <NUM_LIT:3> ] , <NUM_LIT:0.5> ) <EOL> def testSetItem ( self ) : <EOL> numVertices = <NUM_LIT:5> <EOL> graph = self . GraphType ( GeneralVertexList ( numVertices ) ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0.5> ) <EOL> self . assertEquals ( graph [ <NUM_LIT:1> , <NUM_LIT:3> ] , <NUM_LIT:0.5> ) <EOL> graph [ <NUM_LIT:1> , <NUM_LIT:3> ] = <NUM_LIT:2> <EOL> self . assertEquals ( graph [ <NUM_LIT:1> , <NUM_LIT:3> ] , <NUM_LIT:2> ) <EOL> def testToIGraph ( self ) : <EOL> try : <EOL> import igraph <EOL> except ImportError as error : <EOL> logging . debug ( error ) <EOL> return <EOL> numVertices = <NUM_LIT:7> <EOL> graph = self . GraphType ( GeneralVertexList ( numVertices ) ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0.1> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:0.5> ) <EOL> graph . addEdge ( <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:0.1> ) <EOL> graph . setVertex ( <NUM_LIT:1> , "<STR_LIT:a>" ) <EOL> graph . setVertex ( <NUM_LIT:2> , "<STR_LIT:b>" ) <EOL> graph . setVertex ( <NUM_LIT:3> , "<STR_LIT:c>" ) <EOL> igraph = graph . toIGraph ( ) <EOL> self . assertEquals ( len ( igraph . vs ) , graph . getNumVertices ( ) ) <EOL> self . assertEquals ( len ( igraph . es ) , graph . getNumEdges ( ) ) <EOL> self . assertEquals ( igraph . vs [ "<STR_LIT:label>" ] [ <NUM_LIT:1> ] , "<STR_LIT:a>" ) <EOL> self . assertEquals ( igraph . vs [ "<STR_LIT:label>" ] [ <NUM_LIT:2> ] , "<STR_LIT:b>" ) <EOL> self . assertEquals ( igraph . vs [ "<STR_LIT:label>" ] [ <NUM_LIT:3> ] , "<STR_LIT:c>" ) <EOL> edges = igraph . get_edgelist ( ) <EOL> i = <NUM_LIT:0> <EOL> for e in edges : <EOL> self . assertTrue ( graph . getEdge ( e [ <NUM_LIT:0> ] , e [ <NUM_LIT:1> ] ) == igraph . es [ i ] [ "<STR_LIT:value>" ] ) <EOL> i += <NUM_LIT:1> <EOL> def testPickle ( self ) : <EOL> numVertices = <NUM_LIT:10> <EOL> numFeatures = <NUM_LIT:1> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> graph = self . GraphType ( vList ) <EOL> graph [ <NUM_LIT:0> , <NUM_LIT:0> ] = <NUM_LIT:1> <EOL> graph [ <NUM_LIT:3> , <NUM_LIT:5> ] = <NUM_LIT:0.1> <EOL> graph . setVertex ( <NUM_LIT:0> , numpy . array ( [ <NUM_LIT> ] ) ) <EOL> output = pickle . dumps ( graph ) <EOL> newGraph = pickle . loads ( output ) <EOL> graph [ <NUM_LIT:2> , <NUM_LIT:2> ] = <NUM_LIT:1> <EOL> self . assertEquals ( newGraph [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEquals ( newGraph [ <NUM_LIT:3> , <NUM_LIT:5> ] , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( newGraph [ <NUM_LIT:2> , <NUM_LIT:2> ] , <NUM_LIT:0.0> ) <EOL> self . assertEquals ( newGraph . getNumEdges ( ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( newGraph . getNumVertices ( ) , numVertices ) <EOL> self . assertEquals ( newGraph . isUndirected ( ) , True ) <EOL> self . assertEquals ( graph [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph [ <NUM_LIT:3> , <NUM_LIT:5> ] , <NUM_LIT:0.1> ) <EOL> self . assertEquals ( graph [ <NUM_LIT:2> , <NUM_LIT:2> ] , <NUM_LIT:1> ) <EOL> self . assertEquals ( graph . getNumEdges ( ) , <NUM_LIT:3> ) <EOL> self . assertEquals ( graph . getNumVertices ( ) , numVertices ) <EOL> self . assertEquals ( graph . isUndirected ( ) , True ) <EOL> for i in range ( numVertices ) : <EOL> nptst . assert_array_equal ( graph . getVertex ( i ) , newGraph . getVertex ( i ) ) <EOL> def testToDictGraph ( self ) : <EOL> dictGraph = self . graph . toDictGraph ( ) <EOL> edges = self . graph . getAllEdges ( ) <EOL> edges = numpy . array ( edges , numpy . int ) <EOL> for i in range ( edges . shape [ <NUM_LIT:0> ] ) : <EOL> self . assertEquals ( dictGraph [ edges [ i , <NUM_LIT:0> ] , edges [ i , <NUM_LIT:1> ] ] , self . graph [ int ( edges [ i , <NUM_LIT:0> ] ) , int ( edges [ i , <NUM_LIT:1> ] ) ] ) <EOL> dictGraph2 = self . graph2 . toDictGraph ( ) <EOL> edges2 = self . graph2 . getAllEdges ( ) <EOL> for i in range ( edges2 . shape [ <NUM_LIT:0> ] ) : <EOL> self . assertEquals ( dictGraph2 [ edges2 [ i , <NUM_LIT:0> ] , edges2 [ i , <NUM_LIT:1> ] ] , self . graph [ int ( edges2 [ i , <NUM_LIT:0> ] ) , int ( edges2 [ i , <NUM_LIT:1> ] ) ] ) </s>
