def test_diffusionGraph(self): G = metaknowledge.diffusionGraph(self.RC, self.RC) Gcr_ut = metaknowledge.diffusionGraph(self.RC, self.RC, sourceType="CR", targetType="UT") self.assertEqual( metaknowledge.graphStats(G, sentenceString=True), 'The graph has 42 nodes, 1569 edges, 0 isolates, 35 self loops, a density of 0.91115 and a transitivity of 0.894934' ) self.assertEqual( metaknowledge.graphStats(Gcr_ut, sentenceString=True), 'The graph has 528 nodes, 3591 edges, 246 isolates, 0 self loops, a density of 0.0129054 and a transitivity of 0' )
def test_multiGraph(self): G = metaknowledge.diffusionGraph(self.RC, self.RC, labelEdgesBy='PY') metaknowledge.dropEdges(G, dropSelfLoops=True) #multigraphs have issues their edge counts are somewhat unpredictable self.assertEqual( metaknowledge.graphStats(G, stats=('nodes', 'isolates', 'loops'), sentenceString=True), 'The graph has 42 nodes, 0 isolates and 0 self loops')
def test_multiGraph(self): G = metaknowledge.diffusionGraph(self.RC, self.RC, labelEdgesBy = 'PY') metaknowledge.dropEdges(G, dropSelfLoops = True) #multigraphs have issues their edge counts are somewhat unpredictable self.assertEqual(metaknowledge.graphStats(G, stats = ('nodes', 'isolates', 'loops'), sentenceString = True), 'The graph has 42 nodes, 0 isolates and 0 self loops')
def test_diffusionGraph(self): G = metaknowledge.diffusionGraph(self.RC, self.RC) Gcr_ut = metaknowledge.diffusionGraph(self.RC, self.RC, sourceType = "CR", targetType = "UT") self.assertEqual(metaknowledge.graphStats(G, sentenceString = True), 'The graph has 42 nodes, 1569 edges, 0 isolates, 35 self loops, a density of 0.91115 and a transitivity of 0.894934') self.assertEqual(metaknowledge.graphStats(Gcr_ut, sentenceString = True), 'The graph has 528 nodes, 3591 edges, 246 isolates, 0 self loops, a density of 0.0129054 and a transitivity of 0')
def test_multiGraph(self): G = metaknowledge.diffusionGraph(self.RC, self.RC, labelEdgesBy = 'PY') self.assertEqual(metaknowledge.graphStats(G, stats = ('nodes', 'edges', 'isolates', 'loops', 'density')), 'The graph has 33 nodes, 31 edges, 11 isolates, 0 self loops and a density of 0.0293561')
def test_diffusionGraph(self): G = metaknowledge.diffusionGraph(self.RC, self.RC) Gcr_ut = metaknowledge.diffusionGraph(self.RC, self.RC, sourceType = "CR", targetType = "UT") self.assertEqual(metaknowledge.graphStats(G), 'The graph has 33 nodes, 31 edges, 11 isolates, 0 self loops, a density of 0.0293561 and a transitivity of 0.127907') self.assertEqual(metaknowledge.graphStats(Gcr_ut), 'The graph has 525 nodes, 597 edges, 254 isolates, 0 self loops, a density of 0.00217012 and a transitivity of 0') self.assertEqual(G.edges(data = True).pop()[2]['weight'], 1)