Skip to content

Instantly share code, notes, and snippets.

@davidADSP
Last active January 27, 2021 11:28
Show Gist options
  • Select an option

  • Save davidADSP/35648e480685c6b57ce1efad50170c26 to your computer and use it in GitHub Desktop.

Select an option

Save davidADSP/35648e480685c6b57ce1efad50170c26 to your computer and use it in GitHub Desktop.

Revisions

  1. davidADSP revised this gist Jun 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ego_graph.py
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@

    #GET THE SUBGRAPH THAT CONTAINS TENSORFLOW
    for s in subgraphs:
    if SEED in s:
    if 'tensorflow' in s:
    break
    pruned_EG = EG.subgraph(s)

  2. davidADSP revised this gist Jun 19, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ego_graph.py
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@
    EG = nx.ego_graph(G, 'tensorflow', distance = 'distance', radius = 22)

    #FIND THE 2-CONNECTED SUBGRAPHS
    subgraphs = nx.algorithms.connectivity.edge_kcomponents.k_edge_subgraphs(EG, k = 2)
    subgraphs = nx.algorithms.connectivity.edge_kcomponents.k_edge_subgraphs(EG, k = 3)

    #GET THE SUBGRAPH THAT CONTAINS TENSORFLOW
    for s in subgraphs:
  3. davidADSP revised this gist Jun 19, 2020. 1 changed file with 15 additions and 3 deletions.
    18 changes: 15 additions & 3 deletions ego_graph.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    import networkx as nx

    # SAMPLE DATA FORMAT
    #nodes = [('tensorflow', {'count': 13}),
    # ('pytorch', {'count': 6}),
    # ('keras', {'count': 6}),
    @@ -13,11 +14,22 @@
    # ('opencv', 'tensorflow', {'weight': 7, 'distance': 4}),
    # ('spark', 'tensorflow', {'weight': 1, 'distance': 10}), ...]

    #BUILD THE INITIAL FULL GRAPH
    G=nx.Graph()
    G.add_nodes_from(nodes)
    G.add_edges_from(edges)

    EG = nx.ego_graph(G, 'tensorflow', distance = 'distance', radius = 18)
    #BUILD THE EGO GRAPH FOR TENSORFLOW
    EG = nx.ego_graph(G, 'tensorflow', distance = 'distance', radius = 22)

    ego_nodes = EG.nodes()
    ego_edges = EG.edges()
    #FIND THE 2-CONNECTED SUBGRAPHS
    subgraphs = nx.algorithms.connectivity.edge_kcomponents.k_edge_subgraphs(EG, k = 2)

    #GET THE SUBGRAPH THAT CONTAINS TENSORFLOW
    for s in subgraphs:
    if SEED in s:
    break
    pruned_EG = EG.subgraph(s)

    ego_nodes = pruned_EG.nodes()
    ego_edges = pruned_EG.edges()
  4. davidADSP revised this gist Jun 19, 2020. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion ego_graph.py
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,7 @@
    G.add_nodes_from(nodes)
    G.add_edges_from(edges)

    EG = nx.ego_graph(G, 'tensorflow', distance = 'distance', radius = 18)
    EG = nx.ego_graph(G, 'tensorflow', distance = 'distance', radius = 18)

    ego_nodes = EG.nodes()
    ego_edges = EG.edges()
  5. davidADSP created this gist Jun 19, 2020.
    20 changes: 20 additions & 0 deletions ego_graph.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    import networkx as nx

    #nodes = [('tensorflow', {'count': 13}),
    # ('pytorch', {'count': 6}),
    # ('keras', {'count': 6}),
    # ('scikit', {'count': 2}),
    # ('opencv', {'count': 5}),
    # ('spark', {'count': 13}), ...]

    #edges = [('pytorch', 'tensorflow', {'weight': 10, 'distance': 1}),
    # ('keras', 'tensorflow', {'weight': 9, 'distance': 2}),
    # ('scikit', 'tensorflow', {'weight': 8, 'distance': 3}),
    # ('opencv', 'tensorflow', {'weight': 7, 'distance': 4}),
    # ('spark', 'tensorflow', {'weight': 1, 'distance': 10}), ...]

    G=nx.Graph()
    G.add_nodes_from(nodes)
    G.add_edges_from(edges)

    EG = nx.ego_graph(G, 'tensorflow', distance = 'distance', radius = 18)