Beispiel #1
0
    for index in range(0, num_nodes):
        graph[index] = set([])
        for number in range(0, num_nodes):
            if (index != number):
                a = random.random()
                if (a < p):
                    graph[index].add(number)
    return graph


test_graph = random_directed_graph(10000, 0.5)
#print test_graph

#in_degree_test = compute_in_degrees(citation_graph)
#print in_degree_test
normalized = graph.normalized_in_degree(test_graph)
#print normalized

x = normalized.keys()
y = normalized.values()
fig, ax = plt.subplots()

ax.loglog(x,
          y,
          basex=np.e,
          basey=np.e,
          linestyle='None',
          marker='x',
          markeredgecolor='red')
plt.xlabel("Log of in degrees, base e")
plt.ylabel("Log of fraction of in degrees, base e")
Beispiel #2
0
"""
test_graph = graph.make_complete_graph(5)
dpa = DPATrial(5)
print dpa._num_nodes
print dpa._node_numbers
print dpa.run_trial(5)
print dpa._num_nodes
print dpa._node_numbers
print dpa.run_trial(5)
print dpa._num_nodes
print dpa._node_numbers
"""

pseudo_graph = dpa_generator(27770, 12)

normalized = graph.normalized_in_degree(pseudo_graph)
#print normalized

x = normalized.keys()
y = normalized.values()
fig, ax = plt.subplots()

ax.loglog(x,
          y,
          basex=np.e,
          basey=np.e,
          linestyle='None',
          marker='x',
          markeredgecolor='red')
plt.xlabel("Log of in degrees, base e")
plt.ylabel("Log of fraction of in degrees, base e")
"""
test_graph = graph.make_complete_graph(5)
dpa = DPATrial(5)
print dpa._num_nodes
print dpa._node_numbers
print dpa.run_trial(5)
print dpa._num_nodes
print dpa._node_numbers
print dpa.run_trial(5)
print dpa._num_nodes
print dpa._node_numbers
"""
    
pseudo_graph = dpa_generator(27770, 12)

normalized = graph.normalized_in_degree(pseudo_graph)
#print normalized

x = normalized.keys()
y = normalized.values()
fig, ax = plt.subplots()

ax.loglog(x, y, basex = np.e, basey = np.e, linestyle='None', 
           marker='x', markeredgecolor='red')
plt.xlabel("Log of in degrees, base e")
plt.ylabel("Log of fraction of in degrees, base e")
plt.title("Distribution of random-generated DPA graph on a log scale")

def ticks(y, pos):
    return r'$e^{:.0f}$'.format(np.log(y))
    graph = {}
    for index in range(0, num_nodes):
        graph[index] = set([])
        for number in range(0, num_nodes):
            if (index != number):
                a = random.random()
                if (a < p):
                    graph[index].add(number)
    return graph

test_graph = random_directed_graph(10000, 0.5)
#print test_graph

#in_degree_test = compute_in_degrees(citation_graph)
#print in_degree_test    
normalized = graph.normalized_in_degree(test_graph)
#print normalized

x = normalized.keys()
y = normalized.values()
fig, ax = plt.subplots()

ax.loglog(x, y, basex = np.e, basey = np.e, linestyle='None', 
           marker='x', markeredgecolor='red')
plt.xlabel("Log of in degrees, base e")
plt.ylabel("Log of fraction of in degrees, base e")
plt.title("Distribution of a random directed graph on log scale")

def ticks(y, pos):
    return r'$e^{:.0f}$'.format(np.log(y))