def test_directed_node_connectivity():
    G = nx.cycle_graph(10, create_using=nx.DiGraph())  # only one direction
    D = nx.cycle_graph(10).to_directed()  # 2 reciprocal edges
    assert_equal(1, approx.node_connectivity(G))
    assert_equal(1, approx.node_connectivity(G, 1, 4))
    assert_equal(2, approx.node_connectivity(D))
    assert_equal(2, approx.node_connectivity(D, 1, 4))
Exemplo n.º 2
0
def test_global_node_connectivity():
    # Figure 1 chapter on Connectivity
    G = nx.Graph()
    G.add_edges_from(
        [
            (1, 2),
            (1, 3),
            (1, 4),
            (1, 5),
            (2, 3),
            (2, 6),
            (3, 4),
            (3, 6),
            (4, 6),
            (4, 7),
            (5, 7),
            (6, 8),
            (6, 9),
            (7, 8),
            (7, 10),
            (8, 11),
            (9, 10),
            (9, 11),
            (10, 11),
        ]
    )
    assert 2 == approx.local_node_connectivity(G, 1, 11)
    assert 2 == approx.node_connectivity(G)
    assert 2 == approx.node_connectivity(G, 1, 11)
Exemplo n.º 3
0
def test_directed_node_connectivity():
    G = nx.cycle_graph(10, create_using=nx.DiGraph()) # only one direction
    D = nx.cycle_graph(10).to_directed() # 2 reciprocal edges
    assert_equal(1, approx.node_connectivity(G))
    assert_equal(1, approx.node_connectivity(G, 1, 4))
    assert_equal(2,  approx.node_connectivity(D))
    assert_equal(2,  approx.node_connectivity(D, 1, 4))
Exemplo n.º 4
0
def test_global_node_connectivity():
    # Figure 1 chapter on Connectivity
    G = nx.Graph()
    G.add_edges_from([(1,2),(1,3),(1,4),(1,5),(2,3),(2,6),(3,4),
                    (3,6),(4,6),(4,7),(5,7),(6,8),(6,9),(7,8),
                    (7,10),(8,11),(9,10),(9,11),(10,11)])
    assert_equal(2, approx.local_node_connectivity(G,1,11))
    assert_equal(2, approx.node_connectivity(G))
    assert_equal(2, approx.node_connectivity(G,1,11))
Exemplo n.º 5
0
def measure_connectivity(G,grouping = None):
    overall_conn = approx.node_connectivity(G)
    print('Minimum number of nodes that must be removed to disconnect studets: '+str(overall_conn))
    pairwise_conn = approx.all_pairs_node_connectivity(G)
    plt.title('Distribution of Min Removed Nodes to Disconnect Pair')
    plt.hist(pairwise_conn.values())
    avg_cluster = approx.average_clustering(G)
    print('Mean of the fraction of triangles that actually exist over all possible triangles in each neighborhood: '+str(avg_cluster))
Exemplo n.º 6
0
def get_connectivity(prefix, group_id):
    userlist, user_info = load_user(prefix, group_id)
    filename = util.get_full_prefix(prefix) + "group_" + str(
        group_id) + "_user_followers_dic.json"
    myFollowerFinder = follower.FollowerFinder(prefix=prefix,
                                               userlist=userlist)
    """generate and save json file"""
    TYPE = "undirected"
    SAVE_DIR = "gephi/"
    g = Graph(myFollowerFinder.load_file(filename=filename), TYPE)
    g.build_graph()
    g.add_screenname(user_info)
    print len(g.get_graph().nodes())
    print approx.node_connectivity(g.get_graph())
    dic = degree_alg.degree_centrality(g.get_graph())
    print sum(dic.values()) / len(dic)
    return sum(dic.values()) / len(dic)
Exemplo n.º 7
0
def measure_between_group_connectivity(induced, name = '', plots = False):
    overall_conn = approx.node_connectivity(induced)
    print('Minimum number of nodes that must be removed to disconnect studets: '+str(overall_conn))
    pairwise_conn = approx.all_pairs_node_connectivity(induced)
    avg_cluster = approx.average_clustering(induced)
    print('Mean of the fraction of triangles that actually exist over all possible triangles in each neighborhood: '+str(avg_cluster))
    avg_cluster = approx.average_clustering(induced)
    print('Mean of the fraction of triangles that actually exist over all possible triangles in each neighborhood: '+str(avg_cluster))
    
    if plots:
        p.pairwise_conn_dist(pairwise_conn, name)
def test_white_harary1():
    # Figure 1b white and harary (2001)
    # A graph with high adhesion (edge connectivity) and low cohesion
    # (node connectivity)
    G = nx.disjoint_union(nx.complete_graph(4), nx.complete_graph(4))
    G.remove_node(7)
    for i in range(4, 7):
        G.add_edge(0, i)
    G = nx.disjoint_union(G, nx.complete_graph(4))
    G.remove_node(G.order() - 1)
    for i in range(7, 10):
        G.add_edge(0, i)
    assert_equal(1, approx.node_connectivity(G))
Exemplo n.º 9
0
def test_white_harary1():
    # Figure 1b white and harary (2001)
    # A graph with high adhesion (edge connectivity) and low cohesion
    # (node connectivity)
    G = nx.disjoint_union(nx.complete_graph(4), nx.complete_graph(4))
    G.remove_node(7)
    for i in range(4,7):
        G.add_edge(0,i)
    G = nx.disjoint_union(G, nx.complete_graph(4))
    G.remove_node(G.order()-1)
    for i in range(7,10):
        G.add_edge(0,i)
    assert_equal(1, approx.node_connectivity(G))
Exemplo n.º 10
0
def draw_graph():
    """
    Get all edges information and draw the graph of connection of robots.
    """
    token = sign_in(args["-u"], args["-p"])

    req = {"access_token": token}
    resp = access("/api/datagraph", req)
    if resp["code"] != 0:
        print "[ERROR] get robot edges info error"

    # create graph
    G = nx.Graph()

    # add nodes
    # nodes = resp["robot_nodes"]
    # for node in nodes:
    #     graph.add_node(node["username"], group=node["group"])

    # add edges
    edges = resp["robot_edges"]
    weighted_edges = [(e["source"], e["target"], e["weight"]) for e in edges]
    G.add_weighted_edges_from(weighted_edges)

    # export data with GraphML format
    # for example, Cytoscape can read the GraphML format
    nx.write_graphml(G, "static/tmp/test.graphml")

    # draw graph
    nx.draw(G)
    # nx.draw_random(G)
    # nx.draw_circular(G)
    # nx.draw_spectral(G)
    plt.show()  # need optional dependence matplotlab

    # demos the usage of algorithms in networkx
    print approx.node_connectivity(G)
Exemplo n.º 11
0
def vis_degree_distribution(graph, dynasty):
    degree_seq = [d for n, d in graph.degree()]
    print(len(degree_seq), approx.node_connectivity(graph))
    degree = sorted(degree_seq, reverse=True)
    print(min(degree))
    degreeCount = collections.Counter(degree)
    deg, cnt = zip(*degreeCount.items())
    ln_deg = [math.log(i, 10) for i in deg]
    ln_cn = [math.log(i, 10) for i in cnt]
    #     plt.bar(deg, cnt, width=0.8)
    ax = plt.subplot()
    ax.scatter(ln_deg, ln_cn, marker='+')
    # print([i for i in ax.get_xticks()])
    print([10**i for i in ax.get_xticks()])
    ax.set_xticklabels([round(10**i, 1) for i in ax.get_xticks()])
    ax.set_yticklabels([round(10**i, 1) for i in ax.get_yticks()])
    ax.set_title(dynasty[0].upper() + dynasty[1:])
    #plt.yticks()
    ax.set_ylabel('frequency')
    ax.set_xlabel('degree')
    plt.show()
Exemplo n.º 12
0
def test_dodecahedral():
    G = nx.dodecahedral_graph()
    assert_equal(3, approx.node_connectivity(G))
    assert_equal(3, approx.node_connectivity(G, 0, 5))
Exemplo n.º 13
0
def test_octahedral():
    G = nx.octahedral_graph()
    assert_equal(4, approx.node_connectivity(G))
    assert_equal(4, approx.node_connectivity(G, 0, 5))
Exemplo n.º 14
0
def test_empty_graphs():
    for k in range(5, 25, 5):
        G = nx.empty_graph(k)
        assert_equal(0, approx.node_connectivity(G))
        assert_equal(0, approx.node_connectivity(G, 0, 3))
Exemplo n.º 15
0
def test_petersen():
    G = nx.petersen_graph()
    assert_equal(3, approx.node_connectivity(G))
    assert_equal(3, approx.node_connectivity(G, 0, 5))
Exemplo n.º 16
0
def test_dodecahedral():
    G = nx.dodecahedral_graph()
    assert_equal(3, approx.node_connectivity(G))
    assert_equal(3, approx.node_connectivity(G, 0, 5))
Exemplo n.º 17
0
def graphinfo(G):
    nodenum = G.number_of_nodes()
    edgenum = G.size()
    connectivity = approx.node_connectivity(G)
    avgdegree = nx.k_nearest_neighbors(G)
Exemplo n.º 18
0
def ver_medidas(G):
    print(function.info(G))
    """
    Numero minimo de nodos que deben ser removidos para desconectar G
    """
    print("Numero minimo de nodos que deben ser removidos para desconectar G :"+str(approximation.node_connectivity(G)))

    """
    average clustering coefficient of G.
    """
    print("average clustering coefficient of G: "+str(approximation.average_clustering(G)))

    """
    Densidad de un Grafo
    """
    print("Densidad de G: "+str(function.density(G)))

    """
    Assortativity measures the similarity of connections in
    the graph with respect to the node degree.
    Valores positivos de r indican que existe una correlacion entre nodos 
    con grado similar, mientras que un valor negativo indica
    correlaciones entre nodos de diferente grado
    """

    print("degree assortativity:"+str(assortativity.degree_assortativity_coefficient(G)))

    """
    Assortativity measures the similarity of connections
    in the graph with respect to the given attribute.
    """

    print("assortativity for node attributes: "+str(assortativity.attribute_assortativity_coefficient(G,"crime")))

    """
    Grado promedio vecindad
    """
    plt.plot(assortativity.average_neighbor_degree(G).values())
    plt.title("Grado promedio vecindad")
    plt.xlabel("Nodo")
    plt.ylabel("Grado")
    plt.show();

    """
    Grado de Centralidad de cada nodo
    """

    plt.plot(centrality.degree_centrality(G).values())
    plt.title("Grado de centralidad")
    plt.xlabel("Nodo")
    plt.ylabel("Centralidad")
    plt.show();


    """
    Calcular el coeficiente de agrupamiento para nodos
    """

    plt.plot(cluster.clustering(G).values())
    plt.title("coeficiente de agrupamiento")
    plt.xlabel("Nodo")
    plt.show();

    """
    Media coeficiente de Agrupamiento
    """
    print("Coeficiente de agrupamiento de G:"+str(cluster.average_clustering(G)))

    """
    Centro del grafo
    El centro de un grafo G es el subgrafo inducido por el 
    conjunto de vertices de excentricidad minima.

     La  excentricidad  de  v  in  V  se  define  como  la
     distancia maxima desde v a cualquier otro vertice del 
     grafo G siguiendo caminos de longitud minima.
    """

    print("Centro de G:"+ str(distance_measures.center(G)))

    """
    Diametro de un grafo
    The diameter is the maximum eccentricity.
    """
    print("Diametro de G:"+str(distance_measures.diameter(G)))


    """
    Excentricidad de cada Nodo
    The eccentricity of a node v is the maximum distance
    from v to all other nodes in G.
    """
    plt.plot(distance_measures.eccentricity(G).values())
    plt.title("Excentricidad de cada Nodo")
    plt.xlabel("Nodo")
    plt.show();

    """
    Periferia 
    The periphery is the set of nodes with eccentricity equal to the diameter.
    """
    print("Periferia de G:")
    print(distance_measures.periphery(G))

    """
    Radio
    The radius is the minimum eccentricity.

    """

    print("Radio de G:"+str(distance_measures.radius(G)))

    """
    PageRank calcula una clasificacion de los nodos
    en el grafico G en funcion de la estructura de 
    los enlaces entrantes. Originalmente fue disenado
    como un algoritmo para clasificar paginas web.
    """

    plt.plot(link_analysis.pagerank_alg.pagerank(G).values())
    plt.title("Puntaje de cada Nodo")
    plt.xlabel("Nodo")
    plt.show();

    """
    Coeficiente de Small World.
    A graph is commonly classified as small-world if sigma>1.

    """

    print("Coeficiente de Small World: " + str(smallworld.sigma(G)))

    """
    The small-world coefficient (omega) ranges between -1 and 1.
    Values close to 0 means the G features small-world characteristics.
    Values close to -1 means G has a lattice shape whereas values close
    to 1 means G is a random graph.
    """
    print("Omega coeficiente: "+str(smallworld.omega(G)))
Exemplo n.º 19
0
def test_empty_graphs():
    for k in range(5, 25, 5):
        G = nx.empty_graph(k)
        assert_equal(0, approx.node_connectivity(G))
        assert_equal(0, approx.node_connectivity(G, 0, 3))
Exemplo n.º 20
0
def test_octahedral():
    G = nx.octahedral_graph()
    assert 4 == approx.node_connectivity(G)
    assert 4 == approx.node_connectivity(G, 0, 5)
Exemplo n.º 21
0
    print(key,value)

"""                         Assortativity                    """
r=nx.degree_pearson_correlation_coefficient(mastodon_digraph)
print(r)

"""                     Network Analysis Undirected          """
mastodon_undirected = mastodon_digraph.to_undirected()

average_node_degree = nx.average_degree_connectivity(mastodon_undirected)
print ("average node degree", average_node_degree.keys())

average_clustering = approx.average_clustering(mastodon_undirected)
print("Average Clustering: ", average_clustering)

node_connectivity = approx.node_connectivity(mastodon_undirected)
print("Node connectivity: ", node_connectivity)


"""                   Max degree node + Ego Network          """

#find node with largest degree
node_and_degree = mastodon_digraph.degree()
(largest_hub, degree) = sorted(node_and_degree, key=itemgetter(1))[-1]
# Create ego graph of main hub
hub_ego = nx.ego_graph(mastodon_digraph, largest_hub)
# Draw graph
pos = nx.spring_layout(hub_ego)
nx.draw(hub_ego, pos, node_color='b', node_size=50, with_labels=False)
# Draw ego as large and red
nx.draw_networkx_nodes(hub_ego, pos, nodelist=[largest_hub], node_size=300, node_color='r')
Exemplo n.º 22
0
def test_dodecahedral():
    G = nx.dodecahedral_graph()
    assert 3 == approx.node_connectivity(G)
    assert 3 == approx.node_connectivity(G, 0, 5)
Exemplo n.º 23
0
def test_petersen():
    G = nx.petersen_graph()
    assert 3 == approx.node_connectivity(G)
    assert 3 == approx.node_connectivity(G, 0, 5)
Exemplo n.º 24
0
def test_icosahedral():
    G = nx.icosahedral_graph()
    assert_equal(5, approx.node_connectivity(G))
    assert_equal(5, approx.node_connectivity(G, 0, 5))
Exemplo n.º 25
0
def ncnt():
    messagebox.showinfo(
        "Info", "Node Connectivity of the graph is {}".format(
            apxa.node_connectivity(g)))
Exemplo n.º 26
0
def test_icosahedral():
    G=nx.icosahedral_graph()
    assert_equal(5, approx.node_connectivity(G))
    assert_equal(5, approx.node_connectivity(G, 0, 5))
Exemplo n.º 27
0
def test_complete_graphs():
    for n in range(5, 25, 5):
        G = nx.complete_graph(n)
        assert_equal(n-1, approx.node_connectivity(G))
        assert_equal(n-1, approx.node_connectivity(G, 0, 3))
Exemplo n.º 28
0
G.remove_node(13)

G.add_edge(1, 2)
E = (2, 3)
G.add_edge(*E)
G.add_edges_from([(1, 2), (1, 3)])
G.add_edges_from(H.edges())

G.add_edge(1, 8)
G[1][8]['color'] = 'blue'

print '\nDraw out with matplotlib...'
nx.draw(G)
plt.show()

print '\nIterators...'
FG = nx.Graph()
FG.add_weighted_edges_from(
    [(1, 2, 0.125), (1, 3, 0.75), (2, 4, 1.2), (3, 4, 0.375), (1, 4, 0.175)])
for n, nbrs in FG.adjacency_iter():
    for nbr, attr in nbrs.items():
        if attr['weight'] < 0.5:
            print '(%d, %d, %.3f)' % (n, nbr, attr['weight'])

for (u, v, d) in FG.edges(data='weight'):
    if d < 0.5:
        print '(%d, %d, %.3f)' % (u, v, d)

print "\nAlgorithms operators..."
print approx.node_connectivity(G)
Exemplo n.º 29
0
def test_petersen():
    G = nx.petersen_graph()
    assert_equal(3, approx.node_connectivity(G))
    assert_equal(3, approx.node_connectivity(G, 0, 5))
Exemplo n.º 30
0
def test_complete_graphs():
    for n in range(5, 25, 5):
        G = nx.complete_graph(n)
        assert_equal(n - 1, approx.node_connectivity(G))
        assert_equal(n - 1, approx.node_connectivity(G, 0, 3))
Exemplo n.º 31
0
def test_octahedral():
    G=nx.octahedral_graph()
    assert_equal(4, approx.node_connectivity(G))
    assert_equal(4, approx.node_connectivity(G, 0, 5))
Exemplo n.º 32
0
        print('#weakly connected component:\t',
              number_weakly_connected_components(G),
              file=f)
        print('Is strongly connected:\t', is_strongly_connected(G), file=f)
        print('#strongly connected component:\t',
              number_strongly_connected_components(G),
              file=f)

        print('#node in largest SCC:\t',
              len(next(strongly_connected_components(G))),
              file=f)
        print('#node in largest WCC:\t',
              len(next(weakly_connected_components(G))),
              file=f)
        print('node connectivity (approx.):\t',
              approx.node_connectivity(G.to_undirected()),
              file=f)

        # exact, slow
        # print('node connectivity:', node_connectivity(G.to_undirected()))
        # print('edge connectivity:', edge_connectivity(G.to_undirected()))

        #print('------------DAG-------------', file = f)
        print('Is DAG (should be true):\t',
              is_directed_acyclic_graph(G),
              file=f)
        print('Longest path length:\t', dag_longest_path_length(G), file=f)

        #print('--------Clustering--------')
        # exact, slow
        # print('Average clustering coefficient (undirected):', average_clustering(G.to_undirected()))
Exemplo n.º 33
0
 def node_connectivity(network):
     """ Computes the node connectivity for the network. """
     connectivity = approx.node_connectivity(network)
     return connectivity
def conn2(g, row):
    try:
        ret = approx.node_connectivity(g, row.question1, row.question2)
    except:
        return 1
    return ret
Exemplo n.º 35
0
 def graph_node_connectivity(self, source=None, dest=None):
     conn = approx.node_connectivity(self.graph, source, dest)
     return conn
def get_graph_properties(edges):
    # Set up graph
    connections = np.array([int(x) for x in edges.split(';')])

    nodes = sorted(list(set(connections)))
    # Calculate Properties
    properties = []
    timings = {}

    if connections[0] > 0:
        edges = connections.reshape(int(connections.size / 2), 2)
        timeS = time.time()

        # directed graph
        G = nx.DiGraph()
        G.add_edges_from(edges)

        # undirected graph
        U = nx.Graph()
        U.add_edges_from(edges)
        # graph generated

        # property 1: number of components
        num_comp = nx.number_connected_components(U)
        properties.append(num_comp)

        # property 2: number of strongly connected components
        num_strong_comp = nx.number_strongly_connected_components(G)
        properties.append(num_strong_comp)

        # property 3: average in/out degree
        indeg = []
        outdeg = []
        indeg_ls = list(G.in_degree())
        outdeg_ls = list(G.out_degree())

        for x in np.arange(len(nodes)):
            indeg.append(indeg_ls[x][1])
            outdeg.append(outdeg_ls[x][1])
        av_deg = np.mean(indeg)
        properties.append(av_deg)

        # property 4: link density
        linkden = connections.size / (len(nodes) * len(nodes))
        properties.append(linkden)

        # property 5: number of self loops
        numloop = list(G.selfloop_edges())
        numloop = len(numloop)
        properties.append(numloop)
        #       # property 6: number of simple cycles (excluding self loops)
        #       numcyc = list(nx.simple_cycles(G))
        #       numcyc = len(numcyc) - numloop
        #       properties.append(numcyc)

        #       timings.update({'p6':time.time()-timeS})
        #       print('p6')
        #       print(timings['p6'])
        #       timeS = time.time()

        # find all components
        components = list(nx.connected_components(U))

        ischain = [None] * len(components)
        istree = [None] * len(components)
        isdag = [None] * len(components)
        unicel = [None] * len(components)
        isscc = [None] * len(components)
        iscyc = [None] * len(components)
        iseul = [None] * len(components)
        indeg_by_comp = []
        outdeg_by_comp = []
        node_conn = [0] * len(components)
        av_clust = [0.] * len(components)
        assort = [0.] * len(components)
        indeg_cen_av = [0.] * len(components)
        indeg_cen_max = [0.] * len(components)
        indeg_cen_min = [0.] * len(components)
        outdeg_cen_av = [0.] * len(components)
        outdeg_cen_max = [0.] * len(components)
        outdeg_cen_min = [0.] * len(components)
        bet_cen_av = [0.] * len(components)
        bet_cen_max = [0.] * len(components)
        bet_cen_min = [0.] * len(components)
        eig_cen_av = [0.] * len(components)
        eig_cen_max = [0.] * len(components)
        eig_cen_min = [0.] * len(components)
        triangles_av = [0.] * len(components)
        triangles_max = [0.] * len(components)
        triangles_min = [0.] * len(components)
        squares_av = [0.] * len(components)
        squares_max = [0.] * len(components)
        squares_min = [0.] * len(components)
        transitivity = [0.] * len(components)
        rc = [0.] * len(components)
        loopnumber = [0] * len(components)

        for compnum in np.arange(len(components)):
            # property 6: ischain?(remove self-loops and then test this property)
            # want: how many chains does the graph contain.. look at each component, not the whole graph in one go.
            # most graphs are single components.
            G1 = G.subgraph(list(components[compnum]))
            Gnoself = G1.copy()
            Gnoself.remove_edges_from(Gnoself.selfloop_edges())
            Unoself = nx.Graph()
            Unoself.add_edges_from(Gnoself.edges)

            # if all in and out degrees are 1, graph is a chain..do not include in trees
            indeg2 = []
            outdeg2 = []
            indeg_ls2 = list(Gnoself.in_degree())
            outdeg_ls2 = list(Gnoself.out_degree())
            # nx gives indeg and outdeg as tuples (nodename, in/out deg). which is why i need the for loop below
            for x in np.arange(len(G1.nodes())):
                indeg2.append(indeg_ls2[x][1])
                outdeg2.append(outdeg_ls2[x][1])
            indeg_by_comp.append(int_arr_to_str(indeg2, delim=';'))
            outdeg_by_comp.append(int_arr_to_str(outdeg2, delim=';'))

            indeg2 = np.array(indeg2)
            outdeg2 = np.array(outdeg2)
            in_min_out = indeg2 - outdeg2
            ischain[compnum] = int((np.sum(in_min_out) == 0)
                                   & (np.sum(np.abs(in_min_out)) == 2)
                                   & (np.all(indeg2 <= 1))
                                   & (np.all(outdeg2 <= 1)))
            # property 7: istree(remove chains first)
            istree[compnum] = int((nx.is_tree(Gnoself) - ischain[compnum]) > 0)
            # property 8: isdag(only looking at DAGs other than trees and chains)
            isdag[compnum] = int((int(nx.is_directed_acyclic_graph(Gnoself)) -
                                  istree[compnum] - ischain[compnum]) > 0)
            if isdag[compnum] > 0:
                loopnumber[compnum] = len(list(
                    Gnoself.edges)) - (len(list(Gnoself.nodes)) - 1)
            # property 9: single celled
            unicel[compnum] = int(len(Gnoself.nodes) == 1)
            istree[compnum] = int(istree[compnum]) - int(
                unicel[compnum]
            )  # nx counts single node with no self-edge as a tree
            # property 10: isscc (excluding unicellular)
            num_strong_comp2 = nx.number_strongly_connected_components(Gnoself)
            isscc[compnum] = int(num_strong_comp2 == 1)
            isscc[compnum] = int((isscc[compnum] - unicel[compnum]) > 0)
            # property 11: iscyc(cyclic graphs other than those with a single scc and single celled graphs)
            iscyc[compnum] = int((isdag[compnum] + istree[compnum] +
                                  ischain[compnum] + isscc[compnum] +
                                  unicel[compnum]) == 0)
            # property 12: is eulerian
            iseul[compnum] = int(nx.is_eulerian(Gnoself))
            # property 13: node connectivity
            node_conn[compnum] = approx.node_connectivity(Gnoself)
            # property 14: clustering coefficient
            av_clust[compnum] = nx.average_clustering(Gnoself)
            # property 15: assortativity(pearson's coefficient)
            try:
                assort[compnum] = nx.degree_pearson_correlation_coefficient(
                    Gnoself)  #####################check
            except:
                assort[compnum] = 0.0
            # property 16,17,18: in degree centrality (average, maximum and minimum)
            indeg_cen = []
            dict1 = nx.in_degree_centrality(Gnoself)
            for a1 in dict1:
                indeg_cen.append(dict1[a1])
            indeg_cen_av[compnum] = np.average(indeg_cen)
            indeg_cen_max[compnum] = max(indeg_cen)
            indeg_cen_min[compnum] = min(indeg_cen)
            # property 19,20,21: out degree centrality (average, maximum, minimum)
            outdeg_cen = []
            dict1 = nx.out_degree_centrality(Gnoself)
            for a1 in dict1:
                outdeg_cen.append(dict1[a1])
            outdeg_cen_av[compnum] = np.average(outdeg_cen)
            outdeg_cen_max[compnum] = max(outdeg_cen)
            outdeg_cen_min[compnum] = min(outdeg_cen)
            # property 22,23,24: betweenness centrality (average,maximum, minimum)
            bet_cen = []
            dict1 = nx.betweenness_centrality(Gnoself)
            for a1 in dict1:
                bet_cen.append(dict1[a1])
            bet_cen_av[compnum] = np.average(bet_cen)
            bet_cen_max[compnum] = max(bet_cen)
            bet_cen_min[compnum] = min(bet_cen)
            # property 25,26,27: eigen vector centrality (average,maximum, minimum)
            eig_cen = []
            try:
                dict1 = nx.eigenvector_centrality(Gnoself)
                for a1 in dict1:
                    eig_cen.append(dict1[a1])
                eig_cen_av[compnum] = np.average(eig_cen)
                eig_cen_max[compnum] = max(eig_cen)
                eig_cen_min[compnum] = min(eig_cen)
            except nx.PowerIterationFailedConvergence:
                pass
            # property 28,29,30: number of triangles for each node (average,maximum, minimum)
            triangles = []
            dict1 = nx.triangles(Unoself)
            for a1 in dict1:
                triangles.append(dict1[a1])
            if len(triangles):
                triangles_av[compnum] = np.average(triangles)
                triangles_max[compnum] = max(triangles)
                triangles_min[compnum] = min(triangles)
            # property 31: transitivity (fraction of all possible triangles present in the graph)
            transitivity[compnum] = nx.transitivity(Gnoself)
            # property 32,33,34: square clustering for each node(fraction of all possible squares present at a node)
            squares = []
            dict1 = nx.square_clustering(Gnoself)
            for a1 in dict1:
                squares.append(dict1[a1])
            if len(squares):
                squares_av[compnum] = np.average(squares)
                squares_max[compnum] = max(squares)
                squares_min[compnum] = min(squares)
            # propery 35: rich club coefficient
            if len(list(Unoself.nodes())) > 3:
                rc[compnum] = 0.0


#               rc[compnum] = nx.rich_club_coefficient(Unoself).values()# only works if graph has 4 or more edges
# property 36 and 37: number of source and target nodes

        iseul = sum(iseul)
        iscyc = sum(iscyc)
        isscc = sum(isscc)
        unicel = sum(unicel)
        isdag = sum(isdag)
        istree = sum(istree)
        ischain = sum(ischain)
        indeg_by_comp = ';'.join([str(x) for x in indeg_by_comp])
        outdeg_by_comp = ';'.join([str(x) for x in outdeg_by_comp])
        node_conn = ';'.join([str(x) for x in node_conn
                              ])  # node connectivity for each component
        avav_clust = np.average(
            av_clust)  # average clustering coefficient over all components
        av_clust = ';'.join([
            str(round(x, 2)) for x in av_clust
        ])  # average clustering coefficients for each component
        av_assort = np.average(
            assort)  # average assortativity over all components
        assort = ';'.join([str(round(x, 2)) for x in assort
                           ])  # assortativity for each component
        indeg_cen_avav = np.average(
            indeg_cen_av)  # average indeg centrality over all components
        indeg_cen_av = ';'.join([
            str(round(x, 2)) for x in indeg_cen_av
        ])  # average indeg centrality for each component
        indeg_cen_maxmax = max(
            indeg_cen_max)  # maximum indeg centrality across all components
        indeg_cen_max = ';'.join([
            str(round(x, 2)) for x in indeg_cen_max
        ])  # maximum indeg centrality for each component
        indeg_cen_minmin = min(
            indeg_cen_min)  # minimum indeg centrality across all components
        indeg_cen_min = ';'.join([
            str(round(x, 2)) for x in indeg_cen_min
        ])  # minimum indeg centrality for each component

        outdeg_cen_avav = np.average(outdeg_cen_av)
        outdeg_cen_av = ';'.join([str(round(x, 2)) for x in outdeg_cen_av])
        outdeg_cen_maxmax = max(outdeg_cen_max)
        outdeg_cen_max = ';'.join([str(round(x, 2)) for x in outdeg_cen_max])
        outdeg_cen_minmin = min(outdeg_cen_min)
        outdeg_cen_min = ';'.join([str(round(x, 2)) for x in outdeg_cen_min])
        bet_cen_avav = np.average(bet_cen_av)
        bet_cen_av = ';'.join([str(round(x, 2)) for x in bet_cen_av])
        bet_cen_maxmax = max(bet_cen_max)
        bet_cen_max = ';'.join([str(round(x, 2)) for x in bet_cen_max])
        bet_cen_minmin = min(bet_cen_min)
        bet_cen_min = ';'.join([str(round(x, 2)) for x in bet_cen_min])
        eig_cen_avav = np.average(eig_cen_av)
        eig_cen_av = ';'.join([str(round(x, 2)) for x in eig_cen_av])
        eig_cen_maxmax = max(eig_cen_max)
        eig_cen_max = ';'.join([str(round(x, 2)) for x in eig_cen_max])
        eig_cen_minmin = min(eig_cen_min)
        eig_cen_min = ';'.join([str(round(x, 2)) for x in eig_cen_min])
        triangles_avav = np.average(triangles_av)
        triangles_av = ';'.join([str(x) for x in triangles_av])
        triangles_maxmax = max(triangles_max)
        triangles_max = ';'.join([str(x) for x in triangles_max])
        triangles_minmin = min(triangles_min)
        triangles_min = ';'.join([str(x) for x in triangles_min])
        transitivity_av = np.average(transitivity)
        transitivity_max = max(transitivity)
        transitivity_min = min(transitivity)
        transitivity = ';'.join([str(x) for x in transitivity])
        squares_avav = np.average(squares_av)
        squares_maxmax = max(squares_max)
        squares_minmin = min(squares_min)
        squares_av = ';'.join([str(x) for x in squares_av])
        squares_max = ';'.join([str(x) for x in squares_max])
        squares_min = ';'.join([str(x) for x in squares_min])
        rc_av = np.average(rc)
        rc_max = max(rc)
        rc_min = min(rc)
        rc = ';'.join([str(x) for x in rc])
        ln = [loopnumber[x] for x in np.nonzero(loopnumber)[0]]
        if any(ln):
            loopnumber_av = np.average(ln)
        else:
            loopnumber_av = 0.0
        loopnumber = ';'.join([str(x) for x in loopnumber])

        # check.. sum of iscyc, isscc, unicel, dag,tree, chain should be the total number of components
        if num_comp != (iscyc + isscc + unicel + isdag + istree + ischain):
            print('Number of components is wrong!!!!!!')
            print(num_comp)
            print([iscyc, isscc, unicel, isdag, istree, ischain])
            sys.exit()

        properties.append(indeg_by_comp)  # string
        properties.append(outdeg_by_comp)  #string
        properties.append(ischain)  #int
        properties.append(istree)  #int
        properties.append(isdag)  #int
        properties.append(unicel)  #int
        properties.append(isscc)  #int
        properties.append(iscyc)  #int
        properties.append(iseul)  #int
        properties.append(loopnumber_av)  #float
        properties.append(loopnumber)  #string
        properties.append(node_conn)  #string
        properties.append(avav_clust)  #float
        properties.append(av_clust)  #string
        properties.append(av_assort)  #float
        properties.append(assort)  #string
        properties.append(indeg_cen_avav)  #float
        properties.append(indeg_cen_av)  #string
        properties.append(indeg_cen_maxmax)  #float
        properties.append(indeg_cen_max)  #string
        properties.append(indeg_cen_minmin)  #float
        properties.append(indeg_cen_min)  #string
        properties.append(outdeg_cen_avav)  #float
        properties.append(outdeg_cen_av)  #string
        properties.append(outdeg_cen_maxmax)  #float
        properties.append(outdeg_cen_max)  #string
        properties.append(outdeg_cen_minmin)  #float
        properties.append(outdeg_cen_min)  #string
        properties.append(bet_cen_avav)  #float
        properties.append(bet_cen_av)  #string
        properties.append(bet_cen_maxmax)  #float
        properties.append(bet_cen_max)  #string
        properties.append(bet_cen_minmin)  #float
        properties.append(bet_cen_min)  #string
        properties.append(eig_cen_avav)  #float
        properties.append(eig_cen_av)  #string
        properties.append(eig_cen_maxmax)  #float
        properties.append(eig_cen_max)  #string
        properties.append(eig_cen_minmin)  #float
        properties.append(eig_cen_min)  #string
        properties.append(triangles_avav)  #float
        properties.append(triangles_av)  #string
        properties.append(triangles_maxmax)  #float
        properties.append(triangles_max)  #string
        properties.append(triangles_minmin)  #float
        properties.append(triangles_min)  #string
        properties.append(transitivity_av)  # float
        properties.append(transitivity_max)  #float
        properties.append(transitivity_min)  #float
        properties.append(transitivity)  #string
        properties.append(squares_avav)  #float
        properties.append(squares_av)  #string
        properties.append(squares_maxmax)  #float
        properties.append(squares_max)  #string
        properties.append(squares_minmin)  #float
        properties.append(squares_min)  #string
        properties.append(rc_av)  # float
        properties.append(rc_max)  #float
        properties.append(rc_min)  #float
        properties.append(rc)  #string

        # append more properties.....
        # property 14:

        # property x: in-degree sequence
        #indeg = # list(G.in_degree())[iterate over number of nodes][1]
        # property y: out-degree sequence
        #outdeg = # list(G.in_degree())[iterate over number of nodes][1]
        #.....
    else:
        properties = [0] * 2 + [0.] * 2 + [0] + [''] * 2 + [0] * 7 + [
            0.
        ] + [''] * 2 + [0., ''] * 17 + [0.] * 3 + [''] + [0., ''] * 3 + [
            0., 0., 0., ''
        ]

    # return list of properties
    return properties