Ejemplo n.º 1
0
    nx.number_strongly_connected_components(
        artistGraph)) + " strongly connected components."

my_component = artistGraph

for component in nx.strongly_connected_component_subgraphs(artistGraph):
    if search.id in component:
        my_component = component

print "This artist's clique currently contains " + str(
    len(artistGraph)) + " artists."

# Go through the graph and compute each PR until it converges.
iterations = 10
print "Computing PageRank on your searched artist..."
computePR(my_component, 0.85, iterations)

prList = []

for artist in my_component.nodes():
    prList.append((artist, my_component.node[artist]['currPR']))

prList.sort(key=lambda tup: tup[1])  # Sort the list in place

prList.reverse()  # order by descending PR

print("Here are some artists similar to " + str(search.username))

for item in prList[0:10]:
    artist = scac.id2username(item[0])
    print artist, item[1]
Ejemplo n.º 2
0
print "Artist interpreted as: %s" % search.username
# need to compute all neighbors in given graph selection before we can compute the 
# pr of each node. 
print "="*20

my_component = artistGraph

for component in nx.strongly_connected_component_subgraphs(artistGraph):
    if search.id in component:
        my_component = component

# Go through the graph and compute each PR until it converges.
iterations = 10
print "Computing PageRank on your searched artist..."
computePR(my_component , 0.85, iterations)

prList = []

for artist in my_component.nodes():
    prList.append((artist, my_component.node[artist]['currPR']))

prList.sort(key = lambda tup: tup[1]) # Sort the list in place

prList.reverse() # order by descending PR

print ("Here are some artists similar to " + str(search.username) )

for item in prList[0:10]:
    artist = scac.id2username(item[0])
    print artist, item[1]
Ejemplo n.º 3
0
# need to compute all neighbors in given graph selection before we can compute the 
# pr of each node. 

depth = 2
i = 0
for t in range(depth):
	print "Iteration " + str(t)
	current_artists = artistDict.values()
	for artist in current_artists:
		print "Artist " + str(i) + " of " + str(len(current_artists))
		getNeighbors(artist)
		i += 1

# Go through the graph and compute each PR until it converges.
iterations = 10
computePR(artistDict, 0.85, iterations)

prList = []

for artist in artistDict.values():
	prList.append((artist.id, artist.pr[10]))

prList.sort(key = lambda tup: tup[1]) # Sort the list in palce

prList.reverse() # order by descending PR

print ("Here are some artists that " + str(aoi.id) + " is interested in:")
try:
	print aoi.inNeighbors
	print aoi.outNeighbors
	print "The PR of this artist is: " + str(aoi.pr[t])
Ejemplo n.º 4
0
        else:
            print "\t", "Artist ID %s is not query-able" % profile
            unavailable_profiles.append(profile)

print "The profile graph currently contains " + str(len(profileGraph.nodes())) + " profiles."

print "Here are their connections."

print_graph(profileGraph)

print "The profile graph currently contains " + str(nx.number_strongly_connected_components(profileGraph)) + " strongly connected components."

# Go through the graph and compute each PR until it converges.
iterations = 10
print "Computing PageRank on our profileGraph..."
computePR(profileGraph, 0.85, iterations)

prList = []

for profile in profileGraph.nodes():
    prList.append((profile, profileGraph.node[profile]['currPR']))

prList.sort(key = lambda tup: tup[1]) # Sort the list in place

prList.reverse() # order by descending PR

print ("Here are some profiles similar to " + str(search.username) )

for item in prList[0:10]:
        profile = scac.id2username(item[0])
        print profile, item[1]
Ejemplo n.º 5
0
        print "\t", username + " has " + str(len(followings)) + " followings"
        print "\t", username + " follows " + ", ".join(map(lambda x: scac.id2username(x), followings))
        print "\t", username + " has " + str(len(followers)) + " followers"
        print "\t", username + " is followed by " + ", ".join(map(lambda x: scac.id2username(x), followers))
        print "-" * 40

print "The artist graph currently contains " + str(
    nx.number_strongly_connected_components(artistGraph)
) + " strongly connected components."

nx.write_graphml(artistGraph, "artistGraph.graphml")

# Go through the graph and compute each PR until it converges.
iterations = 10
print "Computing PageRank on our artistGraph..."
computePR(artistGraph, 0.85, iterations)

prList = []

for artist in artistGraph.nodes():
    prList.append((artist, artistGraph.node[artist]["currPR"]))

prList.sort(key=lambda tup: tup[1])  # Sort the list in place

prList.reverse()  # order by descending PR

print ("Here are some artists similar to " + str(search.username))

for item in prList[0:10]:
    artist = scac.id2username(item[0])
    print artist, item[1]
Ejemplo n.º 6
0
        else:
            print "\t", "Artist ID %s is not query-able" % profile
            unavailable_profiles.append(profile)

print "The profile graph currently contains " + str(len(profileGraph.nodes())) + " profiles."

print "Here are their connections."

print_graph(profileGraph)

print "The profile graph currently contains " + str(nx.number_strongly_connected_components(profileGraph)) + " strongly connected components."

# Go through the graph and compute each PR until it converges.
iterations = 10
print "Computing PageRank on our profileGraph..."
computePR(profileGraph, 0.85, iterations)

prList = []

for profile in profileGraph.nodes():
    prList.append((profile, profileGraph.node[profile]['currPR']))

prList.sort(key = lambda tup: tup[1]) # Sort the list in place

prList.reverse() # order by descending PR

print ("Here are some profiles similar to " + str(search.username) )

for item in prList[0:10]:
        profile = scac.id2username(item[0])
        print profile, item[1]