<s> import numpy <EOL> from apgl . graph . VertexList import VertexList <EOL> from apgl . graph . SparseGraph import SparseGraph <EOL> from apgl . generator . KroneckerGenerator import KroneckerGenerator <EOL> import unittest <EOL> import logging <EOL> class KroneckerGeneratorTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> pass <EOL> def testGenerate ( self ) : <EOL> k = <NUM_LIT:2> <EOL> numVertices = <NUM_LIT:3> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> initialGraph = SparseGraph ( vList ) <EOL> initialGraph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> initialGraph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> for i in range ( numVertices ) : <EOL> initialGraph . addEdge ( i , i ) <EOL> d = initialGraph . diameter ( ) <EOL> degreeSequence = initialGraph . outDegreeSequence ( ) <EOL> generator = KroneckerGenerator ( initialGraph , k ) <EOL> graph = generator . generate ( ) <EOL> d2 = graph . diameter ( ) <EOL> degreeSequence2 = graph . outDegreeSequence ( ) <EOL> self . assertTrue ( ( numpy . kron ( degreeSequence , degreeSequence ) == degreeSequence2 ) . all ( ) ) <EOL> self . assertTrue ( graph . getNumVertices ( ) == numVertices ** k ) <EOL> self . assertTrue ( graph . getNumDirEdges ( ) == initialGraph . getNumDirEdges ( ) ** k ) <EOL> self . assertEquals ( d , d2 ) <EOL> k = <NUM_LIT:3> <EOL> generator . setK ( k ) <EOL> graph = generator . generate ( ) <EOL> d3 = graph . diameter ( ) <EOL> degreeSequence3 = graph . outDegreeSequence ( ) <EOL> self . assertTrue ( ( numpy . kron ( degreeSequence , degreeSequence2 ) == degreeSequence3 ) . all ( ) ) <EOL> self . assertTrue ( graph . getNumVertices ( ) == numVertices ** k ) <EOL> self . assertTrue ( graph . getNumDirEdges ( ) == initialGraph . getNumDirEdges ( ) ** k ) <EOL> self . assertEquals ( d , d3 ) <EOL> logging . debug ( degreeSequence ) <EOL> logging . debug ( degreeSequence2 ) <EOL> logging . debug ( degreeSequence3 ) <EOL> def testDegreeDistribution ( self ) : <EOL> numVertices = <NUM_LIT:3> <EOL> numFeatures = <NUM_LIT:0> <EOL> vList = VertexList ( numVertices , numFeatures ) <EOL> initialGraph = SparseGraph ( vList ) <EOL> initialGraph . addEdge ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> initialGraph . addEdge ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> for i in range ( numVertices ) : <EOL> initialGraph . addEdge ( i , i ) <EOL> logging . debug ( ( initialGraph . outDegreeSequence ( ) ) ) <EOL> logging . debug ( ( initialGraph . degreeDistribution ( ) ) ) <EOL> k = <NUM_LIT:2> <EOL> generator = KroneckerGenerator ( initialGraph , k ) <EOL> graph = generator . generate ( ) <EOL> logging . debug ( ( graph . outDegreeSequence ( ) ) ) <EOL> logging . debug ( ( graph . degreeDistribution ( ) ) ) <EOL> k = <NUM_LIT:3> <EOL> generator = KroneckerGenerator ( initialGraph , k ) <EOL> graph = generator . generate ( ) <EOL> logging . debug ( ( graph . degreeDistribution ( ) ) ) </s>
