cliques communities
play

Cliques & communities Network Analysis in Python I Cliques - PowerPoint PPT Presentation

NETWORK ANALYSIS IN PYTHON I Cliques & communities Network Analysis in Python I Cliques Social cliques: tightly-knit groups Network cliques: completely connected graphs Network Analysis in Python I Cliques Simplest


  1. NETWORK ANALYSIS IN PYTHON I Cliques & communities

  2. Network Analysis in Python I Cliques ● Social cliques: tightly-knit groups ● Network cliques: completely connected graphs

  3. Network Analysis in Python I Cliques ● Simplest complex clique: a triangle

  4. Network Analysis in Python I Triangle applications ● Friend recommendation systems

  5. Network Analysis in Python I Clique code In [1]: G Out[1]: <networkx.classes.graph.Graph at 0x10c99ecf8> In [2]: from itertools import combinations In [3]: for n1, n2 in combinations(G.nodes(), 2): ...: print(n1, n2) 0 1 0 2 0 3 0 4 0 5 ... ...

  6. NETWORK ANALYSIS IN PYTHON I Let’s practice!

  7. NETWORK ANALYSIS IN PYTHON I Maximal cliques

  8. Network Analysis in Python I Maximal cliques ● Definition: a clique that, when extended by one node is no longer a clique

  9. Network Analysis in Python I Maximal cliques ● Definition: a clique that, when extended by one node is no longer a clique

  10. Network Analysis in Python I Maximal cliques ● Applications: community finding

  11. Network Analysis in Python I Communities ● Find cliques ● Find unions of cliques

  12. Network Analysis in Python I NetworkX API ● find_cliques finds all maximal cliques

  13. Network Analysis in Python I Maximal cliques In [1]: import networkx as nx In [2]: G = nx.barbell_graph(m1=5, m2=1) In [3]: nx.find_cliques(G) Out[3]: <generator object find_cliques at 0x1043f1f68> In [4]: list(nx.find_cliques(G)) Out[4]: [[4, 0, 1, 2, 3], [4, 5], [6, 8, 9, 10, 7], [6, 5]]

  14. NETWORK ANALYSIS IN PYTHON I Let’s practice!

  15. NETWORK ANALYSIS IN PYTHON I Subgraphs

  16. Network Analysis in Python I Subgraphs ● Visualize portions of a large graph ● Paths ● Communities/cliques ● Degrees of separation from a node

  17. Network Analysis in Python I Subgraphs In [1]: import networkx as nx In [2]: G = nx.erdos_renyi_graph(n=20, p=0.2) In [3]: G.nodes() Out[3]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] In [4]: nodes = G.neighbors(8) In [5]: nodes Out[5]: [2, 3, 4, 10] In [6]: nodes.append(8)

  18. Network Analysis in Python I Subgraphs In [7]: G_eight = G.subgraph(nodes) In [8]: G_eight.edges() Out[8]: [(8, 2), (8, 3), (8, 4), (8, 10), (2, 10)] In [9]: G_eight Out[9]: <networkx.classes.graph.Graph at 0x10cae39e8> In [10]: G Out[10]: <networkx.classes.graph.Graph at 0x10cad1f60>

  19. Network Analysis in Python I Subgraphs In [11]: nx.draw(G_eight, with_labels=True)

  20. NETWORK ANALYSIS IN PYTHON I Let’s practice!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend