Exemplo n.º 1
0
def main(args):
    if len(args) < 1:
        print("Usage: ./program <db> <date1> <date2>")
        sys.exit(1)

    db = args[0]
    date1 = args[1]
    date2 = args[2]

    reader = DBReader(db)
    uid = reader.uid()
    print("#uid cache. Length=%d" % len(uid))

    collab_base = reader.collaborators(None, date1)
    print("#collab_base. Length=%d" % len(collab_base))

    Gcollab_base = graphutils.get_db_graph(graphutils.Graph.COLLAB, uid,
                                           collab_base)
    print("#Gcollab_base. Number of nodes=%d" % Gcollab_base.GetNodes())

    G = Gcollab_base.G

    hist = get_degree_histogram(G)
    n = G.GetNodes()

    print("MLE estimate of alpha: %f" % mle(hist))

    mxWccSize = snap.GetMxWccSz(G)
    print("Fraction of nodes in the largest weakly connected component: %f" %
          mxWccSize)

    clustCoff = snap.GetClustCf(G)
    print("Clustering coefficient: %f" % clustCoff)

    avgDeg = sum([item[0] * item[1] for item in hist]) / float(n)
    print("Average Degree: %f" % avgDeg)

    wccHist = get_wcc_histogram(G)
    print("WCC Histogram : ")
    print(wccHist)

    print(mle(wccHist))
Exemplo n.º 2
0
def main(args):
    if len(args) < 1:
        print("Usage: ./program <db> <date1> <date2>")
        sys.exit(1)

    db = args[0]
    date1 = args[1]
    date2 = args[2]

    reader = DBReader(db)
    uid = reader.uid()
    print("#uid cache. Length=%d" % len(uid))

    collab_base = reader.collaborators(None, date1)
    print("#collab_base. Length=%d" % len(collab_base))

    Gcollab_base = graphutils.get_db_graph(graphutils.Graph.COLLAB, uid, collab_base)
    print("#Gcollab_base. Number of nodes=%d" % Gcollab_base.GetNodes())

    G = Gcollab_base.G

    hist = get_degree_histogram(G)
    n = G.GetNodes()

    print("MLE estimate of alpha: %f" % mle(hist))

    mxWccSize = snap.GetMxWccSz(G)
    print("Fraction of nodes in the largest weakly connected component: %f" % mxWccSize)

    clustCoff = snap.GetClustCf(G)
    print("Clustering coefficient: %f" % clustCoff)

    avgDeg = sum([item[0] * item[1] for item in hist]) / float(n)
    print("Average Degree: %f" % avgDeg)

    wccHist = get_wcc_histogram(G)
    print("WCC Histogram : ")
    print(wccHist)

    print(mle(wccHist))
Exemplo n.º 3
0
def main(args):
	db = args[0]
	date1 = args[1]
	userid = args[2]
	
	k=2
	beta= 0

	reader = DBReader(db)
	print("Getting uid")
	uid = reader.uid()
	src = uid[userid]

	print("Userid, rowid: %s, %d"%(userid, src))

	print("Getting all the base graphs")

	
	'''
	Gcollab_base = graphutils.get_collab_graph(db, uid)
	assert(Gcollab_base.IsNode(src))

	feature_graphs = graphutils.get_feat_graphs(db, uid, None, date1)
	base_graphs = graphutils.get_base_dict(Gcollab_base, feature_graphs)

	# from base graph take a random source node in every iteration
	baseG = base_graphs[graphutils.Graph.COLLAB]
	featG = graphutils.split_feat_graphs(base_graphs)

	'''
	followers = reader.followers()
	baseG = graphutils.get_db_graph(graphutils.Graph.FOLLOW, uid, followers)
	Gp = snapext.EUNGraph()
	featG = [Gp, Gp, Gp]
	
	subBaseG= graphutils.getSubGraph(baseG, src, 5)
	topIDs = runrw.runrw(subBaseG, featG, src, beta)[:20]	
	print reader.get_users(topIDs)
Exemplo n.º 4
0
def main(args):
    db = args[0]
    date1 = args[1]
    userid = args[2]

    k = 2
    beta = 0

    reader = DBReader(db)
    print("Getting uid")
    uid = reader.uid()
    src = uid[userid]

    print("Userid, rowid: %s, %d" % (userid, src))

    print("Getting all the base graphs")
    '''
	Gcollab_base = graphutils.get_collab_graph(db, uid)
	assert(Gcollab_base.IsNode(src))

	feature_graphs = graphutils.get_feat_graphs(db, uid, None, date1)
	base_graphs = graphutils.get_base_dict(Gcollab_base, feature_graphs)

	# from base graph take a random source node in every iteration
	baseG = base_graphs[graphutils.Graph.COLLAB]
	featG = graphutils.split_feat_graphs(base_graphs)

	'''
    followers = reader.followers()
    baseG = graphutils.get_db_graph(graphutils.Graph.FOLLOW, uid, followers)
    Gp = snapext.EUNGraph()
    featG = [Gp, Gp, Gp]

    subBaseG = graphutils.getSubGraph(baseG, src, 5)
    topIDs = runrw.runrw(subBaseG, featG, src, beta)[:20]
    print reader.get_users(topIDs)
Exemplo n.º 5
0
print("Getting all the base graphs")
'''
Gcollab_base = graphutils.get_collab_graph(db, uid)
assert(Gcollab_base.IsNode(src))

feature_graphs = graphutils.get_feat_graphs(db, uid, None, date1)
base_graphs = graphutils.get_base_dict(Gcollab_base, feature_graphs)

# from base graph take a random source node in every iteration
baseG = base_graphs[graphutils.Graph.COLLAB]
featG = graphutils.split_feat_graphs(base_graphs)

'''
followers = reader.followers()
baseG = graphutils.get_db_graph(graphutils.Graph.FOLLOW, uid, followers)

#Gp = snapext.EUNGraph()
#featG = [Gp, Gp, Gp]

featG = graphutils.split_feat_graphs(
    graphutils.get_feat_graphs(db, uid, None, date1))


class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_head()
        SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)

    def send_head(self):
        self.send_header("Content-type", "application/json")
Exemplo n.º 6
0
print("Getting all the base graphs")

'''
Gcollab_base = graphutils.get_collab_graph(db, uid)
assert(Gcollab_base.IsNode(src))

feature_graphs = graphutils.get_feat_graphs(db, uid, None, date1)
base_graphs = graphutils.get_base_dict(Gcollab_base, feature_graphs)

# from base graph take a random source node in every iteration
baseG = base_graphs[graphutils.Graph.COLLAB]
featG = graphutils.split_feat_graphs(base_graphs)

'''
followers = reader.followers()
baseG = graphutils.get_db_graph(graphutils.Graph.FOLLOW, uid, followers)

#Gp = snapext.EUNGraph()
#featG = [Gp, Gp, Gp]

featG = graphutils.split_feat_graphs(graphutils.get_feat_graphs(db, uid, None, date1))

class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):

	def end_headers(self):
		self.send_head()
		SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)

	def send_head(self):
		self.send_header("Content-type", "application/json")
		self.send_header("Access-Control-Allow-Origin", "*")