|
5 | 5 |
|
6 | 6 | * Graph Basics and NetworkX
|
7 | 7 |
|
| 8 | +** Introduction |
| 9 | + |
| 10 | +- Networks and connections found everywhere |
| 11 | + - Transportation with roads and rail tracks |
| 12 | + - Airplane networks |
| 13 | + - Social networks |
| 14 | + - Internet |
| 15 | + - Biological networks e.g. food web or molecular networks |
| 16 | +- Mathematics calls these *graphs* |
| 17 | +- Graphs are collection of two things: |
| 18 | + - objects or nodes or vertices |
| 19 | + - edges or connections |
| 20 | + |
| 21 | +** NetworkX |
| 22 | + |
| 23 | +- NetworkX is Python package to: |
| 24 | + - Create networks, |
| 25 | + - Manipulate networks, and |
| 26 | + - Study networks |
| 27 | + |
| 28 | +#+BEGIN_SRC python |
| 29 | +import networkx as nx |
| 30 | +import matplotlib.pyplot as plt |
| 31 | +#+END_SRC |
| 32 | + |
| 33 | +** Network Basics and Motivation |
| 34 | + |
| 35 | +- Nodes and edges can have multiple attributes |
| 36 | + - Think of social network |
| 37 | + - Individuals can be described in multiple ways |
| 38 | + - Relationships between the individuals can vary |
| 39 | + |
| 40 | +- There are different graph types |
| 41 | + - Undirected graphs, or simply a graph |
| 42 | + - Directed graphs, or digraphs |
| 43 | + |
| 44 | +| Type | Alternate Name | Description | NetworkX Call | |
| 45 | +|------------------+----------------+------------------------------+--------------------| |
| 46 | +| Undirected graph | Graph | Graphs with undirected edges | ~G = nx.Graph()~ | |
| 47 | +| Directed graph | Digraph | Graphs with directed edges | ~G = nx.DiGraph()~ | |
| 48 | + |
| 49 | +- Studying networks is powerful |
| 50 | + - Reveal properties of a population or system that otherwise is hidden |
| 51 | + - Understanding patterns that are a result of the kinds of connections |
| 52 | + - Understand strength or robustness of a system |
| 53 | + |
| 54 | +** Objectives |
| 55 | + |
| 56 | +- Ability to describe a parts to make a graph |
| 57 | +- Describe what are attributes for nodes and edges |
| 58 | +- Describe basic metrics to describe graph |
| 59 | +- Understanding how to use Matplotlib to visualize and plot results |
| 60 | +- Describe basic analysis to be done on networks |
| 61 | + |
8 | 62 | * Working with Nodes and Objects
|
9 | 63 |
|
| 64 | +| Command | Description | |
| 65 | +|-----------------------------+-----------------------------------------------| |
| 66 | +| ~nodes(G)~ | Return iterator over the graph nodes | |
| 67 | +| ~number_of_nodes(G)~ | Return number of nodes in graph | |
| 68 | +| ~all_neighbors(G, node)~ | Return all neighbors of node in graph | |
| 69 | +| ~non_neighbors(G, node)~ | Return non-neighbors of node in graph | |
| 70 | +| ~common_neighbors(G, u, v)~ | Return common neighbors of two nodes in graph | |
| 71 | + |
| 72 | +#+BEGIN_SRC python |
| 73 | +# Create (empty) graph with no nodes and no edges |
| 74 | +G = nx.Graph() |
| 75 | +#+END_SRC |
| 76 | + |
10 | 77 | * Working with Edges and Connections
|
11 | 78 |
|
| 79 | +| Command | Description | |
| 80 | +|----------------------+------------------------------------| |
| 81 | +| ~edges(G)~ | Return edge view of edges | |
| 82 | +| ~number_of_edges(G)~ | Return number of edges in graph | |
| 83 | +| ~non_edges(G)~ | Return non-existent edges in graph | |
| 84 | + |
| 85 | +* Node and Edge Attributes |
| 86 | + |
| 87 | +| Type | Command | Description | |
| 88 | +|------+----------------------------------+----------------------------------------------------| |
| 89 | +| Node | ~set_node_attributes(G, values)~ | Set node attributes from given value or dictionary | |
| 90 | +| Node | ~get_node_attributes(G, name)~ | Get node attributes from graph | |
| 91 | +| Edge | ~set_edge_attributes(G, values)~ | Set edge attributes from given value or dictionary | |
| 92 | +| Edge | ~get_edge_attributes(G, name)~ | Get edge attributes from graph | |
| 93 | + |
12 | 94 | * Drawing Graphs in Different Ways
|
13 | 95 |
|
| 96 | +| Command | Description | |
| 97 | +|-----------+----------------------------| |
| 98 | +| ~draw(G)~ | Draw graph with Matplotlib | |
| 99 | +| | | |
| 100 | + |
14 | 101 | * Analyzing Graph Metrics
|
15 | 102 |
|
16 | 103 | ** Degree of Nodes
|
|
33 | 120 |
|
34 | 121 | * Resources
|
35 | 122 |
|
36 | | -- [[https://networkx.github.io/][NetworkX]] |
37 | | -- [[http://igraph.org/][igraph]] |
38 | | -- [[http://networksciencebook.com/][Network Science by Albert-László Barabási]] |
| 123 | +- Tools |
| 124 | + - [[https://networkx.github.io/][NetworkX]] |
| 125 | + - [[http://igraph.org/][igraph]] |
| 126 | +- Network science |
| 127 | + - [[http://networksciencebook.com/][Network Science by Albert-László Barabási]] |
| 128 | + - [[https://mathigon.org/course/graphs-and-networks/introduction][Graphs and Networks - Mathigon]] |
| 129 | + - [[https://plus.maths.org/content/graphs-and-networks][Graphs and Networks - Plus Magazine]] |
0 commit comments