Experimenting with Assortativity 1. Characterising a Simple Network (A

Total Page:16

File Type:pdf, Size:1020Kb

Experimenting with Assortativity 1. Characterising a Simple Network (A Experimenting with Assortativity 1. Characterising a simple network (a) Using networkx , load the second version of the airport dataset (graphml) (b) Compute the assortativity of the country attribute, using attribute assortativity coefficient function. What does it mean? (c) Compute the degree assortativity using the degree assortativity coefficient function. What does it mean? (d) Compare the degree assortativity with a randomized version of the graph, to check if it is similar or significantly different (e) Compute the average degrees of neighbors using average degree connectivity . You can plot it, for instance as a scatter plot. (f) Do the same analyis of degree assortativity and correlation on other networks, for instance those included in networkx such as nx.karate club graph() or nx.les miserables graph() (g) In a previous experiment, you computed communities on the airport graph and saved these com- munities as an attribute. Compute the assortativity coefficient of the community structure, and compare it with the one obtained for countries. What do you think of the results? 2. Going further : Network→Assortativity→Network (a) Using the attribute mixing dict function, you can compute the number of edges between nodes of a given attribute. Use this to create a network in which nodes correspond to countries. (tip: the Graph() constructor function of networkx accept dictionaries.) (b) Try to plot and characterize quickly this network. (c) To obtain a more interesting network, we should keep only links between countries which are not expected by chance, given the degree of countries. Using formula of the assortativity coefficient as an inspiration, propose a way to create such a network. Beware negative values... (d) Plot this network and compare it with the one obtained with the naive approach..
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]
  • 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]
  • 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]
  • 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]
  • Robustness and Assortativity for Diffusion-Like Processes in Scale
    epl draft Robustness and Assortativity for Diffusion-like Processes in Scale- free Networks G. D’Agostino1, A. Scala2,3, V. Zlatic´4 and G. Caldarelli5,3 1 ENEA - CR ”Casaccia” - Via Anguillarese 301 00123, Roma - Italy 2 CNR-ISC and Department of Physics, University of Rome “Sapienza” P.le Aldo Moro 5 00185 Rome, Italy 3 London Institute of Mathematical Sciences, 22 South Audley St Mayfair London W1K 2NY, UK 4 Theoretical Physics Division, Rudjer Boˇskovi´cInstitute, P.O.Box 180, HR-10002 Zagreb, Croatia 5 IMT Lucca Institute for Advanced Studies, Piazza S. Ponziano 6, Lucca, 55100, Italy PACS 89.75.Hc – Networks and genealogical trees PACS 05.70.Ln – Nonequilibrium and irreversible thermodynamics PACS 87.23.Ge – Dynamics of social systems Abstract – By analysing the diffusive dynamics of epidemics and of distress in complex networks, we study the effect of the assortativity on the robustness of the networks. We first determine by spectral analysis the thresholds above which epidemics/failures can spread; we then calculate the slowest diffusional times. Our results shows that disassortative networks exhibit a higher epidemi- ological threshold and are therefore easier to immunize, while in assortative networks there is a longer time for intervention before epidemic/failure spreads. Moreover, we study by computer sim- ulations the sandpile cascade model, a diffusive model of distress propagation (financial contagion). We show that, while assortative networks are more prone to the propagation of epidemic/failures, degree-targeted immunization policies increases their resilience to systemic risk. Introduction. – The heterogeneity in the distribu- propagation of an epidemic [13–15].
    [Show full text]
  • Ollivier Ricci Curvature of Directed Hypergraphs Marzieh Eidi1* & Jürgen Jost1,2
    www.nature.com/scientificreports OPEN Ollivier Ricci curvature of directed hypergraphs Marzieh Eidi1* & Jürgen Jost1,2 Many empirical networks incorporate higher order relations between elements and therefore are naturally modelled as, possibly directed and/or weighted, hypergraphs, rather than merely as graphs. In order to develop a systematic tool for the statistical analysis of such hypergraph, we propose a general defnition of Ricci curvature on directed hypergraphs and explore the consequences of that defnition. The defnition generalizes Ollivier’s defnition for graphs. It involves a carefully designed optimal transport problem between sets of vertices. While the defnition looks somewhat complex, in the end we shall be able to express our curvature in a very simple formula, κ = µ0 − µ2 − 2µ3 . This formula simply counts the fraction of vertices that have to be moved by distances 0, 2 or 3 in an optimal transport plan. We can then characterize various classes of hypergraphs by their curvature. Principles of network analysis. Network analysis constitutes one of the success stories in the study of complex systems3,6,11. For the mathematical analysis, a network is modelled as a (perhaps weighted and/or directed) graph. One can then look at certain graph theoretical properties of an empirical network, like its degree or motiv distribution, its assortativity or clustering coefcient, the spectrum of its Laplacian, and so on. One can also compare an empirical network with certain deterministic or random theoretical models. Successful as this analysis clearly is, we nevertheless see two important limitations. One is that many of the prominent concepts and quantities used in the analysis of empirical networks are node based, like the degree sequence.
    [Show full text]
  • Assortativity and Mixing
    Assortativity and Assortativity and Mixing General mixing between node categories Mixing Assortativity and Mixing Definition Definition I Assume types of nodes are countable, and are Complex Networks General mixing General mixing Assortativity by assigned numbers 1, 2, 3, . Assortativity by CSYS/MATH 303, Spring, 2011 degree degree I Consider networks with directed edges. Contagion Contagion References an edge connects a node of type µ References e = Pr Prof. Peter Dodds µν to a node of type ν Department of Mathematics & Statistics Center for Complex Systems aµ = Pr(an edge comes from a node of type µ) Vermont Advanced Computing Center University of Vermont bν = Pr(an edge leads to a node of type ν) ~ I Write E = [eµν], ~a = [aµ], and b = [bν]. I Requirements: X X X eµν = 1, eµν = aµ, and eµν = bν. µ ν ν µ Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. 1 of 26 4 of 26 Assortativity and Assortativity and Outline Mixing Notes: Mixing Definition Definition General mixing General mixing Assortativity by I Varying eµν allows us to move between the following: Assortativity by degree degree Definition Contagion 1. Perfectly assortative networks where nodes only Contagion References connect to like nodes, and the network breaks into References subnetworks. General mixing P Requires eµν = 0 if µ 6= ν and µ eµµ = 1. 2. Uncorrelated networks (as we have studied so far) Assortativity by degree For these we must have independence: eµν = aµbν . 3. Disassortative networks where nodes connect to nodes distinct from themselves. Contagion I Disassortative networks can be hard to build and may require constraints on the eµν.
    [Show full text]
  • Extraction and Analysis of Facebook Friendship Relations
    Chapter 12 Extraction and Analysis of Facebook Friendship Relations Salvatore Catanese, Pasquale De Meo, Emilio Ferrara, Giacomo Fiumara, and Alessandro Provetti Abstract Online social networks (OSNs) are a unique web and social phenomenon, affecting tastes and behaviors of their users and helping them to maintain/create friendships. It is interesting to analyze the growth and evolution of online social networks both from the point of view of marketing and offer of new services and from a scientific viewpoint, since their structure and evolution may share similarities with real-life social networks. In social sciences, several techniques for analyzing (off-line) social networks have been developed, to evaluate quantitative properties (e.g., defining metrics and measures of structural characteristics of the networks) or qualitative aspects (e.g., studying the attachment model for the network evolution, the binary trust relationships, and the link prediction problem). However, OSN analysis poses novel challenges both to computer and Social scientists. We present our long-term research effort in analyzing Facebook, the largest and arguably most successful OSN today: it gathers more than 500 million users. Access to data about Facebook users and their friendship relations is restricted; thus, we acquired the necessary information directly from the front end of the website, in order to reconstruct a subgraph representing anonymous interconnections among a significant subset of users. We describe our ad hoc, privacy-compliant crawler for Facebook data extraction. To minimize bias, we adopt two different graph mining techniques: breadth-first-search (BFS) and rejection sampling. To analyze the structural properties of samples consisting of millions of nodes, we developed a S.Catanese•P.DeMeo•G.Fiumara Department of Physics, Informatics Section.
    [Show full text]
  • The Perceived Assortativity of Social Networks: Methodological Problems and Solutions
    The perceived assortativity of social networks: Methodological problems and solutions David N. Fisher1, Matthew J. Silk2 and Daniel W. Franks3 Abstract Networks describe a range of social, biological and technical phenomena. An important property of a network is its degree correlation or assortativity, describing how nodes in the network associate based on their number of connections. Social networks are typically thought to be distinct from other networks in being assortative (possessing positive degree correlations); well-connected individuals associate with other well-connected individuals, and poorly-connected individuals associate with each other. We review the evidence for this in the literature and find that, while social networks are more assortative than non-social networks, only when they are built using group-based methods do they tend to be positively assortative. Non-social networks tend to be disassortative. We go on to show that connecting individuals due to shared membership of a group, a commonly used method, biases towards assortativity unless a large enough number of censuses of the network are taken. We present a number of solutions to overcoming this bias by drawing on advances in sociological and biological fields. Adoption of these methods across all fields can greatly enhance our understanding of social networks and networks in general. 1 1. Department of Integrative Biology, University of Guelph, Guelph, ON, N1G 2W1, Canada. Email: [email protected] (primary corresponding author) 2. Environment and Sustainability Institute, University of Exeter, Penryn Campus, Penryn, TR10 9FE, UK Email: [email protected] 3. Department of Biology & Department of Computer Science, University of York, York, YO10 5DD, UK Email: [email protected] Keywords: Assortativity; Degree assortativity; Degree correlation; Null models; Social networks Introduction Network theory is a useful tool that can help us explain a range of social, biological and technical phenomena (Pastor-Satorras et al 2001; Girvan and Newman 2002; Krause et al 2007).
    [Show full text]
  • Graph and Network Analysis
    Graph and Network Analysis Dr. Derek Greene Clique Research Cluster, University College Dublin Web Science Doctoral Summer School 2011 Tutorial Overview • Practical Network Analysis • Basic concepts • Network types and structural properties • Identifying central nodes in a network • Communities in Networks • Clustering and graph partitioning • Finding communities in static networks • Finding communities in dynamic networks • Applications of Network Analysis Web Science Summer School 2011 2 Tutorial Resources • NetworkX: Python software for network analysis (v1.5) http://networkx.lanl.gov • Python 2.6.x / 2.7.x http://www.python.org • Gephi: Java interactive visualisation platform and toolkit. http://gephi.org • Slides, full resource list, sample networks, sample code snippets online here: http://mlg.ucd.ie/summer Web Science Summer School 2011 3 Introduction • Social network analysis - an old field, rediscovered... [Moreno,1934] Web Science Summer School 2011 4 Introduction • We now have the computational resources to perform network analysis on large-scale data... http://www.facebook.com/note.php?note_id=469716398919 Web Science Summer School 2011 5 Basic Concepts • Graph: a way of representing the relationships among a collection of objects. • Consists of a set of objects, called nodes, with certain pairs of these objects connected by links called edges. A B A B C D C D Undirected Graph Directed Graph • Two nodes are neighbours if they are connected by an edge. • Degree of a node is the number of edges ending at that node. • For a directed graph, the in-degree and out-degree of a node refer to numbers of edges incoming to or outgoing from the node.
    [Show full text]