# Tony Hyun Kim
# 2013 10 22
# CS 224w, PS 2, Problem 3

import numpy as np
import snap

# Load the graphs
#------------------------------------------------------------
G1 = snap.LoadEdgeList(snap.PUNGraph, "g1.edgelist", 0, 1)
G2 = snap.LoadEdgeList(snap.PUNGraph, "g2.edgelist", 0, 1)

# Determine the highest rollers of the graph
#------------------------------------------------------------
init_vote = {0: 1,
             1: 1,
             2: 1,
             3: 1,
             4: -1,
             5: -1,
             6: -1,
             7: -1,
             8: 0,
             9: 0}

G = G2

high_rollers = []
while (len(high_rollers) < 20):
    nid = snap.GetMxDegNId(G)

    # Target nodes that were not hard-wired for candidate A
    #if (True):
    if (init_vote[nid % 10] != 1):
        high_rollers.append(nid)
        n = G.GetNI(nid)
        print "node {} has degree {}".format(nid, n.GetOutDeg())

    G.DelNode(nid)
