def conduct_triad_analysis(labelled_data, pid_dict):
    # get the basic networkx graphing constructs
    p, np, edges, ground_edges, polarity_count = create_graph_constructs(labelled_data, pid_dict)

    # get a random distribution of polarity
    random_edges, random_dist, random_labels = get_random_edge_polarity(polarity_count, edges)

    # create graph
    graph = creategraph()
    graph.addnodes(p, 'P')
    graph.addnodes(np, 'NP')
    graph.addedges(edges)
    deg_dist = get_degree_distribution(graph, p)


    # create random graph
    graph_rand = creategraph()
    graph_rand.addnodes(p, 'P')
    graph_rand.addnodes(np, 'NP')
    graph_rand.addedges(random_edges)
    deg_dist_rand = get_degree_distribution(graph_rand, np)

    triad_dict = find_triads(graph, pid_dict, min_participants=2)
    triad_dict_rand = find_triads(graph_rand, pid_dict, min_participants=2)

    # summarize the types of edges
    summary_triad, frac_triad = summarize_triad(triad_dict)
    summary_triad_rand, frac_triad_rand = summarize_triad(triad_dict_rand)

    return [graph, triad_dict, summary_triad, frac_triad, deg_dist], \
           [graph_rand, triad_dict_rand, summary_triad_rand, frac_triad_rand, deg_dist_rand]
def createstaticgraph(pid_dict, data_list):
    links, links_tuple = hlp.getlinks(pid_dict, data_list)
    graph_obj = creategraph(True)
    for p_type in pid_dict.keys():
        graph_obj.addnodes(pid_dict[p_type], p_type)
    graph_obj.addedges(links_tuple)
    return graph_obj
def weekgraphs(week_dict, participant_list, non_participant_list):
    graph_objs = {}
    for week_no in week_dict.keys():
        print 'week no', week_no
        graph_obj = creategraph(True)
        nodes, link_tuple = getnodesedges(week_dict[week_no])
        p_nodes, np_nodes = checknodemembership(nodes, participant_list, non_participant_list)
        graph_obj.addnodes(p_nodes, 'P')
        graph_obj.addnodes(np_nodes, 'NP')
        graph_obj.addedges(link_tuple)
        print 'Calculating properties'
        toStore = {'object': graph_obj.getgraphobject(),
                   'triadic_census': graph_obj.gettriadiccensus(),
                   'closeness': graph_obj.getclosenesscentrality()}
        graph_objs[week_no] = toStore
    return graph_objs