Graphs and Networks with Networkx

Total Page:16

File Type:pdf, Size:1020Kb

Graphs and Networks with Networkx graphs and networks with networkx 1 Python Software for Complex Networks networkx defining and drawing graphs 2 Analysis of Graphs connectivity of random graphs shortest paths 3 Graph Isomorphism are two graphs isomorphic? nauty and Traces 4 Directed Graphs defining and drawing digraphs computing the maximum flow MCS 507 Lecture 25 Mathematical, Statistical and Scientific Software Jan Verschelde, 23 October 2019 Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 1 / 35 graphs and networks with networkx 1 Python Software for Complex Networks networkx defining and drawing graphs 2 Analysis of Graphs connectivity of random graphs shortest paths 3 Graph Isomorphism are two graphs isomorphic? nauty and Traces 4 Directed Graphs defining and drawing digraphs computing the maximum flow Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 2 / 35 networkx Python software for complex networks NetworkX is a free Python library for graphs and networks. Its core is written in pure Python. It interfaces easily with code written in C/C++ and FORTRAN. Initial release: 11 April 2005, v2.4 released 16 October 2019. Aric A. Hagberg, Daniel A. Schult, Pieter J. Swart: Exploring Network Structure, Dynamics, and Function using NetworkX. In the Proceedings of the 7th Python in Science conference (SciPy 2008), pages 11-15. Scales to 10 million nodes and 100 million edges. Integrated into SageMath. web site: http://networkx.github.com Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 3 / 35 graphs and networks with networkx 1 Python Software for Complex Networks networkx defining and drawing graphs 2 Analysis of Graphs connectivity of random graphs shortest paths 3 Graph Isomorphism are two graphs isomorphic? nauty and Traces 4 Directed Graphs defining and drawing digraphs computing the maximum flow Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 4 / 35 adding nodes to a graph Let us make a tree with a root and 5 children. To add a single node, use the method add_node(), to add a list of nodes, use add_nodes_from(). import networkx as nx T = nx.Graph() T.add_node(’root’) children = range(5) T.add_nodes_from(children) print(’the nodes :’, T.nodes()) The output is the nodes : [’root’, 0, 1, 2, 3, 4] Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 5 / 35 adding edges to a graph To add a single edge, use the method add_edge(), to add a list of edges, use add_edges_from(). The script of the previous slide continues below: T.add_edge(’root’, 0) edges = [(’root’, child) for child in children[1:]] T.add_edges_from(edges) print(’the edges :’, T.edges()) The output is the edges : [(’root’, 0), (’root’, 1), (’root’, 2), \ (’root’, 3), (’root’, 4)] Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 6 / 35 number of nodes, edges; list the neighbors print(’the number of nodes :’, T.number_of_nodes()) print(’the number of edges :’, T.number_of_edges()) rootneighbors = T.neighbors(’root’) print(’neighbors of root : ’, end=’’) print([neighbor for neighbor in rootneighbors]) print(’number of neighbors of root :’, T.degree(’root’)) print(’number of neighbors of 2 :’, T.degree(2)) The output is the number of nodes : 6 the number of edges : 5 neighbors of root : [0, 1, 2, 3, 4] number of neighbors of root : 5 number of neighbors of 2 : 1 Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 7 / 35 drawing graphs with matplotlib NetworkX contains many examples of classic graphs. The code below defines a complete bipartite graph with 3 and 5 nodes in each part. import networkx as nx from matplotlib import pyplot as plt k_3_5 = nx.complete_bipartite_graph(3, 5) nx.draw_circular(k_3_5) plt.show() Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 8 / 35 a complete bipartite graph K3,5 Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 9 / 35 graphs and networks with networkx 1 Python Software for Complex Networks networkx defining and drawing graphs 2 Analysis of Graphs connectivity of random graphs shortest paths 3 Graph Isomorphism are two graphs isomorphic? nauty and Traces 4 Directed Graphs defining and drawing digraphs computing the maximum flow Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 10 / 35 connectivity of random graphs Consider the following problem: 1 n is the number of nodes in a graph G; 2 p is the probability that two nodes are connected. What is the probability that G is connected? To explore this problem, we define random graphs. For each pair (i, j) of nodes, we flip a loaded coin to decide whether there is an edge between i and j. Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 11 / 35 graphs from numpy matrices import numpy as np import networkx as nx from random import random, seed from matplotlib import pyplot as plt seed(20191023) p = 0.057 # probability nodes are connected coinflip = lambda: (1 if random() < p else 0) dim = 20 flips = [[coinflip() for j in range(dim)] \ for i in range(dim)] print(flips) A = np.matrix(flips, dtype=int) print(A.shape) G = nx.from_numpy_matrix(A) Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 12 / 35 the adjacency matrix of a graph We can verify that the adjacency matrix is A: print(G.nodes()) print(G.edges()) B = nx.adjacency_matrix(G) C = nx.to_numpy_matrix(G) The nodes are [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, \ 11, 12, 13, 14, 15, 16, 17, 18, 19] and the edges are [(0, 10), (0, 19), (1, 2), (1, 11), (1, 16), (1, 3), \ (1, 10), (2, 16), (3, 17), (5, 13), (6, 6), (6, 8), \ (7, 19), (8, 10), (8, 15), (9, 9), (9, 15), (10, 19), \ (12, 18), (12, 19), (13, 16)] The adjacency matrix depends on the node labeling. Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 13 / 35 the connectivity of a graph print(’Is G connected ?’, nx.is_connected(G)) print(’number of connected components :’, \ nx.number_connected_components(G)) print(’connected components :’, [c for c in nx.connected_components(G)]) nx.draw_networkx(G, pos=nx.circular_layout(G)) plt.show() The output is Is G connected ? False number of connected components : 3 connected components : [{0, 1, 2, 3, 5, 6, 7, 8, 9, \ 10, 11, 12, 13, 15, 16, 17, 18, 19}, {4}, {14}] Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 14 / 35 a random graph with 20 nodes Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 15 / 35 graphs and networks with networkx 1 Python Software for Complex Networks networkx defining and drawing graphs 2 Analysis of Graphs connectivity of random graphs shortest paths 3 Graph Isomorphism are two graphs isomorphic? nauty and Traces 4 Directed Graphs defining and drawing digraphs computing the maximum flow Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 16 / 35 computing shortest paths For a graph G defined by an adjacency matrix A we compute all shortest paths from node 0: G = nx.from_numpy_matrix(A) for i in range(1, 20): try: P = nx.all_shortest_paths(G, 0, i) print(’paths from 0 to’, i, ’:’, [p for p in P]) except: print(i, ’cannot be reached from 0’) An exception occurs if no path exists. Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 17 / 35 output on a random graph paths from 0 to 1 : [[0, 10, 1]] paths from 0 to 2 : [[0, 10, 1, 2]] paths from 0 to 3 : [[0, 10, 1, 3]] 4 cannot be reached from 0 paths from 0 to 5 : [[0, 10, 1, 16, 13, 5]] paths from 0 to 6 : [[0, 10, 8, 6]] paths from 0 to 7 : [[0, 19, 7]] paths from 0 to 8 : [[0, 10, 8]] paths from 0 to 9 : [[0, 10, 8, 15, 9]] paths from 0 to 10 : [[0, 10]] paths from 0 to 11 : [[0, 10, 1, 11]] paths from 0 to 12 : [[0, 19, 12]] paths from 0 to 13 : [[0, 10, 1, 16, 13]] 14 cannot be reached from 0 paths from 0 to 15 : [[0, 10, 8, 15]] paths from 0 to 16 : [[0, 10, 1, 16]] paths from 0 to 17 : [[0, 10, 1, 3, 17]] paths from 0 to 18 : [[0, 19, 12, 18]] paths from 0 to 19 : [[0, 19]] Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 18 / 35 graphs and networks with networkx 1 Python Software for Complex Networks networkx defining and drawing graphs 2 Analysis of Graphs connectivity of random graphs shortest paths 3 Graph Isomorphism are two graphs isomorphic? nauty and Traces 4 Directed Graphs defining and drawing digraphs computing the maximum flow Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 19 / 35 the isomorphism of two graphs The two graphs below are isomorphic: a = B, b = A, c = D, d = C. Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 20 / 35 defining two graphs import networkx as nx from matplotlib import pyplot as plt G = nx.Graph() G.add_nodes_from([’a’, ’b’, ’c’, ’d’]) G.add_edges_from([(’a’, ’b’), (’a’, ’c’), \ (’b’, ’c’), (’b’, ’d’), (’c’, ’d’)]) H = nx.Graph() H.add_nodes_from([’A’, ’B’, ’C’, ’D’]) H.add_edges_from([(’A’, ’B’), (’A’, ’C’), \ (’A’, ’D’), (’B’, ’D’), (’C’, ’D’)]) Scientific Software (MCS 507) graphs and networks with networkx L-25 23 October 2019 21 / 35 computing whether two graphs are isomorphic print(’Are G and H isomorphic?’, \ nx.is_isomorphic(G, H)) fig = plt.figure() ax = fig.add_subplot(211) nx.draw_networkx(G, pos=nx.circular_layout(G), \ node_color=’r’) ax = fig.add_subplot(212) nx.draw_networkx(H, pos=nx.circular_layout(H),
Recommended publications
  • Sagemath and Sagemathcloud
    Viviane Pons Ma^ıtrede conf´erence,Universit´eParis-Sud Orsay [email protected] { @PyViv SageMath and SageMathCloud Introduction SageMath SageMath is a free open source mathematics software I Created in 2005 by William Stein. I http://www.sagemath.org/ I Mission: Creating a viable free open source alternative to Magma, Maple, Mathematica and Matlab. Viviane Pons (U-PSud) SageMath and SageMathCloud October 19, 2016 2 / 7 SageMath Source and language I the main language of Sage is python (but there are many other source languages: cython, C, C++, fortran) I the source is distributed under the GPL licence. Viviane Pons (U-PSud) SageMath and SageMathCloud October 19, 2016 3 / 7 SageMath Sage and libraries One of the original purpose of Sage was to put together the many existent open source mathematics software programs: Atlas, GAP, GMP, Linbox, Maxima, MPFR, PARI/GP, NetworkX, NTL, Numpy/Scipy, Singular, Symmetrica,... Sage is all-inclusive: it installs all those libraries and gives you a common python-based interface to work on them. On top of it is the python / cython Sage library it-self. Viviane Pons (U-PSud) SageMath and SageMathCloud October 19, 2016 4 / 7 SageMath Sage and libraries I You can use a library explicitly: sage: n = gap(20062006) sage: type(n) <c l a s s 'sage. interfaces .gap.GapElement'> sage: n.Factors() [ 2, 17, 59, 73, 137 ] I But also, many of Sage computation are done through those libraries without necessarily telling you: sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage : G . g a p () Group( [ (3,4), (1,2,3)(4,5) ] ) Viviane Pons (U-PSud) SageMath and SageMathCloud October 19, 2016 5 / 7 SageMath Development model Development model I Sage is developed by researchers for researchers: the original philosophy is to develop what you need for your research and share it with the community.
    [Show full text]
  • Networkx Tutorial
    5.03.2020 tutorial NetworkX tutorial Source: https://github.com/networkx/notebooks (https://github.com/networkx/notebooks) Minor corrections: JS, 27.02.2019 Creating a graph Create an empty graph with no nodes and no edges. In [1]: import networkx as nx In [2]: G = nx.Graph() By definition, a Graph is a collection of nodes (vertices) along with identified pairs of nodes (called edges, links, etc). In NetworkX, nodes can be any hashable object e.g. a text string, an image, an XML object, another Graph, a customized node object, etc. (Note: Python's None object should not be used as a node as it determines whether optional function arguments have been assigned in many functions.) Nodes The graph G can be grown in several ways. NetworkX includes many graph generator functions and facilities to read and write graphs in many formats. To get started though we'll look at simple manipulations. You can add one node at a time, In [3]: G.add_node(1) add a list of nodes, In [4]: G.add_nodes_from([2, 3]) or add any nbunch of nodes. An nbunch is any iterable container of nodes that is not itself a node in the graph. (e.g. a list, set, graph, file, etc..) In [5]: H = nx.path_graph(10) file:///home/szwabin/Dropbox/Praca/Zajecia/Diffusion/Lectures/1_intro/networkx_tutorial/tutorial.html 1/18 5.03.2020 tutorial In [6]: G.add_nodes_from(H) Note that G now contains the nodes of H as nodes of G. In contrast, you could use the graph H as a node in G.
    [Show full text]
  • Directed Graph Algorithms
    Directed Graph Algorithms CSE 373 Data Structures Readings • Reading Chapter 13 › Sections 13.3 and 13.4 Digraphs 2 Topological Sort 142 322 143 321 Problem: Find an order in which all these courses can 326 be taken. 370 341 Example: 142 Æ 143 Æ 378 Æ 370 Æ 321 Æ 341 Æ 322 Æ 326 Æ 421 Æ 401 378 421 In order to take a course, you must 401 take all of its prerequisites first Digraphs 3 Topological Sort Given a digraph G = (V, E), find a linear ordering of its vertices such that: for any edge (v, w) in E, v precedes w in the ordering B C A F D E Digraphs 4 Topo sort – valid solution B C Any linear ordering in which A all the arrows go to the right F is a valid solution D E A B F C D E Note that F can go anywhere in this list because it is not connected. Also the solution is not unique. Digraphs 5 Topo sort – invalid solution B C A Any linear ordering in which an arrow goes to the left F is not a valid solution D E A B F C E D NO! Digraphs 6 Paths and Cycles • Given a digraph G = (V,E), a path is a sequence of vertices v1,v2, …,vk such that: ›(vi,vi+1) in E for 1 < i < k › path length = number of edges in the path › path cost = sum of costs of each edge • A path is a cycle if : › k > 1; v1 = vk •G is acyclic if it has no cycles.
    [Show full text]
  • Graph Varieties Axiomatized by Semimedial, Medial, and Some Other Groupoid Identities
    Discussiones Mathematicae General Algebra and Applications 40 (2020) 143–157 doi:10.7151/dmgaa.1344 GRAPH VARIETIES AXIOMATIZED BY SEMIMEDIAL, MEDIAL, AND SOME OTHER GROUPOID IDENTITIES Erkko Lehtonen Technische Universit¨at Dresden Institut f¨ur Algebra 01062 Dresden, Germany e-mail: [email protected] and Chaowat Manyuen Department of Mathematics, Faculty of Science Khon Kaen University Khon Kaen 40002, Thailand e-mail: [email protected] Abstract Directed graphs without multiple edges can be represented as algebras of type (2, 0), so-called graph algebras. A graph is said to satisfy an identity if the corresponding graph algebra does, and the set of all graphs satisfying a set of identities is called a graph variety. We describe the graph varieties axiomatized by certain groupoid identities (medial, semimedial, autodis- tributive, commutative, idempotent, unipotent, zeropotent, alternative). Keywords: graph algebra, groupoid, identities, semimediality, mediality. 2010 Mathematics Subject Classification: 05C25, 03C05. 1. Introduction Graph algebras were introduced by Shallon [10] in 1979 with the purpose of providing examples of nonfinitely based finite algebras. Let us briefly recall this concept. Given a directed graph G = (V, E) without multiple edges, the graph algebra associated with G is the algebra A(G) = (V ∪ {∞}, ◦, ∞) of type (2, 0), 144 E. Lehtonen and C. Manyuen where ∞ is an element not belonging to V and the binary operation ◦ is defined by the rule u, if (u, v) ∈ E, u ◦ v := (∞, otherwise, for all u, v ∈ V ∪ {∞}. We will denote the product u ◦ v simply by juxtaposition uv. Using this representation, we may view any algebraic property of a graph algebra as a property of the graph with which it is associated.
    [Show full text]
  • Networkx: Network Analysis with Python
    NetworkX: Network Analysis with Python Salvatore Scellato Full tutorial presented at the XXX SunBelt Conference “NetworkX introduction: Hacking social networks using the Python programming language” by Aric Hagberg & Drew Conway Outline 1. Introduction to NetworkX 2. Getting started with Python and NetworkX 3. Basic network analysis 4. Writing your own code 5. You are ready for your project! 1. Introduction to NetworkX. Introduction to NetworkX - network analysis Vast amounts of network data are being generated and collected • Sociology: web pages, mobile phones, social networks • Technology: Internet routers, vehicular flows, power grids How can we analyze this networks? Introduction to NetworkX - Python awesomeness Introduction to NetworkX “Python package for the creation, manipulation and study of the structure, dynamics and functions of complex networks.” • Data structures for representing many types of networks, or graphs • Nodes can be any (hashable) Python object, edges can contain arbitrary data • Flexibility ideal for representing networks found in many different fields • Easy to install on multiple platforms • Online up-to-date documentation • First public release in April 2005 Introduction to NetworkX - design requirements • Tool to study the structure and dynamics of social, biological, and infrastructure networks • Ease-of-use and rapid development in a collaborative, multidisciplinary environment • Easy to learn, easy to teach • Open-source tool base that can easily grow in a multidisciplinary environment with non-expert users
    [Show full text]
  • Graph Database Fundamental Services
    Bachelor Project Czech Technical University in Prague Faculty of Electrical Engineering F3 Department of Cybernetics Graph Database Fundamental Services Tomáš Roun Supervisor: RNDr. Marko Genyk-Berezovskyj Field of study: Open Informatics Subfield: Computer and Informatic Science May 2018 ii Acknowledgements Declaration I would like to thank my advisor RNDr. I declare that the presented work was de- Marko Genyk-Berezovskyj for his guid- veloped independently and that I have ance and advice. I would also like to thank listed all sources of information used Sergej Kurbanov and Herbert Ullrich for within it in accordance with the methodi- their help and contributions to the project. cal instructions for observing the ethical Special thanks go to my family for their principles in the preparation of university never-ending support. theses. Prague, date ............................ ........................................... signature iii Abstract Abstrakt The goal of this thesis is to provide an Cílem této práce je vyvinout webovou easy-to-use web service offering a database službu nabízející databázi neorientova- of undirected graphs that can be searched ných grafů, kterou bude možno efektivně based on the graph properties. In addi- prohledávat na základě vlastností grafů. tion, it should also allow to compute prop- Tato služba zároveň umožní vypočítávat erties of user-supplied graphs with the grafové vlastnosti pro grafy zadané uži- help graph libraries and generate graph vatelem s pomocí grafových knihoven a images. Last but not least, we implement zobrazovat obrázky grafů. V neposlední a system that allows bulk adding of new řadě je také cílem navrhnout systém na graphs to the database and computing hromadné přidávání grafů do databáze a their properties.
    [Show full text]
  • Structural Graph Theory Meets Algorithms: Covering And
    Structural Graph Theory Meets Algorithms: Covering and Connectivity Problems in Graphs Saeed Akhoondian Amiri Fakult¨atIV { Elektrotechnik und Informatik der Technischen Universit¨atBerlin zur Erlangung des akademischen Grades Doktor der Naturwissenschaften Dr. rer. nat. genehmigte Dissertation Promotionsausschuss: Vorsitzender: Prof. Dr. Rolf Niedermeier Gutachter: Prof. Dr. Stephan Kreutzer Gutachter: Prof. Dr. Marcin Pilipczuk Gutachter: Prof. Dr. Dimitrios Thilikos Tag der wissenschaftlichen Aussprache: 13. October 2017 Berlin 2017 2 This thesis is dedicated to my family, especially to my beautiful wife Atefe and my lovely son Shervin. 3 Contents Abstract iii Acknowledgementsv I. Introduction and Preliminaries1 1. Introduction2 1.0.1. General Techniques and Models......................3 1.1. Covering Problems.................................6 1.1.1. Covering Problems in Distributed Models: Case of Dominating Sets.6 1.1.2. Covering Problems in Directed Graphs: Finding Similar Patterns, the Case of Erd}os-P´osaproperty.......................9 1.2. Routing Problems in Directed Graphs...................... 11 1.2.1. Routing Problems............................. 11 1.2.2. Rerouting Problems............................ 12 1.3. Structure of the Thesis and Declaration of Authorship............. 14 2. Preliminaries and Notations 16 2.1. Basic Notations and Defnitions.......................... 16 2.1.1. Sets..................................... 16 2.1.2. Graphs................................... 16 2.2. Complexity Classes................................
    [Show full text]
  • Katz Centrality for Directed Graphs • Understand How Katz Centrality Is an Extension of Eigenvector Centrality to Learning Directed Graphs
    Prof. Ralucca Gera, [email protected] Applied Mathematics Department, ExcellenceNaval Postgraduate Through Knowledge School MA4404 Complex Networks Katz Centrality for directed graphs • Understand how Katz centrality is an extension of Eigenvector Centrality to Learning directed graphs. Outcomes • Compute Katz centrality per node. • Interpret the meaning of the values of Katz centrality. Recall: Centralities Quality: what makes a node Mathematical Description Appropriate Usage Identification important (central) Lots of one-hop connections The number of vertices that Local influence Degree from influences directly matters deg Small diameter Lots of one-hop connections The proportion of the vertices Local influence Degree centrality from relative to the size of that influences directly matters deg C the graph Small diameter |V(G)| Lots of one-hop connections A weighted degree centrality For example when the Eigenvector centrality to high centrality vertices based on the weight of the people you are (recursive formula): neighbors (instead of a weight connected to matter. ∝ of 1 as in degree centrality) Recall: Strongly connected Definition: A directed graph D = (V, E) is strongly connected if and only if, for each pair of nodes u, v ∈ V, there is a path from u to v. • The Web graph is not strongly connected since • there are pairs of nodes u and v, there is no path from u to v and from v to u. • This presents a challenge for nodes that have an in‐degree of zero Add a link from each page to v every page and give each link a small transition probability controlled by a parameter β. u Source: http://en.wikipedia.org/wiki/Directed_acyclic_graph 4 Katz Centrality • Recall that the eigenvector centrality is a weighted degree obtained from the leading eigenvector of A: A x =λx , so its entries are 1 λ Thoughts on how to adapt the above formula for directed graphs? • Katz centrality: ∑ + β, Where β is a constant initial weight given to each vertex so that vertices with zero in degree (or out degree) are included in calculations.
    [Show full text]
  • A Gentle Introduction to Deep Learning for Graphs
    A Gentle Introduction to Deep Learning for Graphs Davide Bacciua, Federico Erricaa, Alessio Michelia, Marco Poddaa aDepartment of Computer Science, University of Pisa, Italy. Abstract The adaptive processing of graph data is a long-standing research topic that has been lately consolidated as a theme of major interest in the deep learning community. The snap increase in the amount and breadth of related research has come at the price of little systematization of knowledge and attention to earlier literature. This work is a tutorial introduction to the field of deep learn- ing for graphs. It favors a consistent and progressive presentation of the main concepts and architectural aspects over an exposition of the most recent liter- ature, for which the reader is referred to available surveys. The paper takes a top-down view of the problem, introducing a generalized formulation of graph representation learning based on a local and iterative approach to structured in- formation processing. Moreover, it introduces the basic building blocks that can be combined to design novel and effective neural models for graphs. We com- plement the methodological exposition with a discussion of interesting research challenges and applications in the field. Keywords: deep learning for graphs, graph neural networks, learning for structured data arXiv:1912.12693v2 [cs.LG] 15 Jun 2020 1. Introduction Graphs are a powerful tool to represent data that is produced by a variety of artificial and natural processes. A graph has a compositional nature, being a compound of atomic information pieces, and a relational nature, as the links defining its structure denote relationships between the linked entities.
    [Show full text]
  • Networkx Reference Release 1.9.1
    NetworkX Reference Release 1.9.1 Aric Hagberg, Dan Schult, Pieter Swart September 20, 2014 CONTENTS 1 Overview 1 1.1 Who uses NetworkX?..........................................1 1.2 Goals...................................................1 1.3 The Python programming language...................................1 1.4 Free software...............................................2 1.5 History..................................................2 2 Introduction 3 2.1 NetworkX Basics.............................................3 2.2 Nodes and Edges.............................................4 3 Graph types 9 3.1 Which graph class should I use?.....................................9 3.2 Basic graph types.............................................9 4 Algorithms 127 4.1 Approximation.............................................. 127 4.2 Assortativity............................................... 132 4.3 Bipartite................................................. 141 4.4 Blockmodeling.............................................. 161 4.5 Boundary................................................. 162 4.6 Centrality................................................. 163 4.7 Chordal.................................................. 184 4.8 Clique.................................................. 187 4.9 Clustering................................................ 190 4.10 Communities............................................... 193 4.11 Components............................................... 194 4.12 Connectivity..............................................
    [Show full text]
  • Graph Mining: Social Network Analysis and Information Diffusion
    Graph Mining: Social network analysis and Information Diffusion Davide Mottin, Konstantina Lazaridou Hasso Plattner Institute Graph Mining course Winter Semester 2016 Lecture road Introduction to social networks Real word networks’ characteristics Information diffusion GRAPH MINING WS 2016 2 Paper presentations ▪ Link to form: https://goo.gl/ivRhKO ▪ Choose the date(s) you are available ▪ Choose three papers according to preference (there are three lists) ▪ Choose at least one paper for each course part ▪ Register to the mailing list: https://lists.hpi.uni-potsdam.de/listinfo/graphmining-ws1617 GRAPH MINING WS 2016 3 What is a social network? ▪Oxford dictionary A social network is a network of social interactions and personal relationships GRAPH MINING WS 2016 4 What is an online social network? ▪ Oxford dictionary An online social network (OSN) is a dedicated website or other application, which enables users to communicate with each other by posting information, comments, messages, images, etc. ▪ Computer science : A network that consists of a finite number of users (nodes) that interact with each other (edges) by sharing information (labels, signs, edge directions etc.) GRAPH MINING WS 2016 5 Definitions ▪Vertex/Node : a user of the social network (Twitter user, an author in a co-authorship network, an actor etc.) ▪Edge/Link/Tie : the connection between two vertices referring to their relationship or interaction (friend-of relationship, re-tweeting activity, etc.) Graph G=(V,E) symbols meaning V users E connections deg(u) node degree:
    [Show full text]
  • Exploring Network Structure, Dynamics, and Function Using Networkx
    Proceedings of the 7th Python in Science Conference (SciPy 2008) Exploring Network Structure, Dynamics, and Function using NetworkX Aric A. Hagberg ([email protected])– Los Alamos National Laboratory, Los Alamos, New Mexico USA Daniel A. Schult ([email protected])– Colgate University, Hamilton, NY USA Pieter J. Swart ([email protected])– Los Alamos National Laboratory, Los Alamos, New Mexico USA NetworkX is a Python language package for explo- and algorithms, to rapidly test new hypotheses and ration and analysis of networks and network algo- models, and to teach the theory of networks. rithms. The core package provides data structures The structure of a network, or graph, is encoded in the for representing many types of networks, or graphs, edges (connections, links, ties, arcs, bonds) between including simple graphs, directed graphs, and graphs nodes (vertices, sites, actors). NetworkX provides ba- with parallel edges and self-loops. The nodes in Net- sic network data structures for the representation of workX graphs can be any (hashable) Python object simple graphs, directed graphs, and graphs with self- and edges can contain arbitrary data; this flexibil- loops and parallel edges. It allows (almost) arbitrary ity makes NetworkX ideal for representing networks objects as nodes and can associate arbitrary objects to found in many different scientific fields. edges. This is a powerful advantage; the network struc- In addition to the basic data structures many graph ture can be integrated with custom objects and data algorithms are implemented for calculating network structures, complementing any pre-existing code and properties and structure measures: shortest paths, allowing network analysis in any application setting betweenness centrality, clustering, and degree dis- without significant software development.
    [Show full text]