Find the fractal dimension of a real network using the side coverage algorithm

here, in the following code, I get the colors assigned to the vertices, but there is no value for the field length 'l'

I want the colors to be assigned wrt the length of the boxes and the function should output the number of different colors in the network, so that I can use it to determine the fractal dimension of a real network, according to the law,

N B ~ l B -d B

please help me achieve this.

a dolphin file contains two columns, each of which represents two ends of an edge.

import networkx as nx import matplotlib.pyplot as plt G=nx.Graph() colors = ['c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'c10', 'c11', 'c12'] f = open("real_network/dolphin") a = [int(n) for n in f.read().split()] G.add_nodes_from(a) i = 0 b = [] while i<len(a): b.append((a[i],a[i+1])) i = i+2 #print b G.add_edges_from(b) colors_of_nodes={} def coloring(node, color): for neighbor in G.neighbors(node): color_of_neighbor = colors_of_nodes.get(neighbor, None) if color_of_neighbor == color: return False return True def get_color_for_node(node): for color in colors: if coloring(node, color): return color def main(): for node in G.nodes(): colors_of_nodes[node] = get_color_for_node(node) print colors_of_nodes main() 
+4
source share

All Articles