Network Analysis tutorial: Types of Graphs

preview_player
Показать описание

From online social networks such as Facebook and Twitter to transportation networks such as bike sharing systems, networks are everywhere, and knowing how to analyze this type of data will open up a new world of possibilities for you as a Data Scientist. This course will equip you with the skills to analyze, visualize, and make sense of networks. You'll apply the concepts you learn to real-world network data using the powerful NetworkX library. With the knowledge gained in this course, you'll develop your network thinking skills and be able to start looking at your data with a fresh perspective!

Transcript:
Great work! We are now going to go a little bit deeper into the NetworkX API and introduce a few more concepts that you can use in network analysis.

NetworkX allows us to model different types of graphs. For example, there are social graphs like Facebook, which are undirected graphs. Undirected graphs are named as such because they are comprised of edges that don't have any inherent directionality associated with them. With Facebook, for example, when one user befriends another, the two are automatically connected with an edge. This is commonly drawn as a line with no arrows between two circles.

If we explore this in the IPython terminal, you can instantiate an empty graph in NetworkX using nx.Graph() and ask for its type. Undirected graphs have the type Graph.

On the other hand, Twitter’s social graph is a directed network. This is because of the nature of how users interact with one another. For example, one user may follow another, but that other user may not follow back. As such, there is an inherent directionality associated with the graph.

If we explore this in the IPython terminal, you can instantiate an empty directed graph in NetworkX using nx.DiGraph(). If you query for its type, it will return a DiGraph object.

We can also have graphs in which there are multiple edges permitted between the nodes. For example, we may want to model trips between bike sharing stations. Each trip may be one edge between the pair of stations.

If we explore this in the IPython terminal, we can likewise instantiate a MultiGraph using nx.MultiGraph(). If we check for its type, it will be of the MultiGraph class. Likewise for the MultiDiGraph object.

Sometimes, for practical reasons, it may be too memory-intensive to model multiple edges per pair of nodes, and so one may choose to collapse the edges into a single edge that contains a metadata summary of the original. For example, we may want to collapse these three edges into a single one and give them a “weight” metadata with the value “3”, indicating that it was originally 3 edges between the pair of nodes.

Let’s go through one final concept: the idea of self-loops. Self-loops can be used in certain scenarios, such as in bike sharing data, where a trip begins at a station and end at the same station.

One of the exercises you will encounter will leverage what you’ve learned so far about the NetworkX API to find edges that are self-loops in a graph.

Рекомендации по теме
Комментарии
Автор

Instagram can also be an example of directed graph.

hemanthsivakumar
join shbcf.ru