Get startedGet started for free

Relationships between vertices

1. Relationships between vertices

One of the advantages of social network analysis is that it is possible to evaluate how the overall patterning of relationships between vertices varies between networks. There are many methods for doing this. In this video you will learn how to identify neighbors of vertices as well as paths through networks.

2. Identifying neighbors

Here is our example network from the previous videos with some extra vertices and edges added. The simplest method of assessing relationships between vertices is to identify the neighbors for a given vertex. This can be done using the neighbors function in igraph. The first argument should be the graph object - represented here by 'g'. The second argument is the vertex of interest - let's choose "F". Finally, the third argument is to identify all neighbors as seen here using mode is equal to 'all'. It is also possible to only identify neighbors that F projects an edge to or neighbors that F receives an edge from.

3. Identifying neighbors in common

Although vertices may not be connected directly with an edge, they may have an indirect influence on each other. For instance, in the example network, "F" and "D" are not connected to each other but they do share a common connection with one other vertex - "A". You can identify these connections in common using the function intersection in igraph. First, determine the neighbors of each vertex of interest and assign these to objects. Here we assign the neighbors of F to 'x' and the neighbors of D to 'y'. Next, we can use intersection() as illustrated - this function will return those vertices that both F and D are connected to.

4. Paths

One measure of how well connected a network is is to measure the length of paths between all pairs of vertices. If a vertex is reachable from its neighbor then the path length (also known as geodesic distance) between them is 1. So, J and D have a path length of 1, as do F and A. Similarly, L and A have a path length of 2, as two connections are required to go from L to A. Commonly in network analysis, we are interested in the longest such path that exists in a given network. This is also called the diameter of the network. In this network the diameter (colored in blue) is 6. You can find the diameter in any network using farthest_vertices() which will return the diameter distance and the two vertices at either end of the longest path. get_diameter() will return the exact sequence of connections. If there is more than one longest path, these functions will return only one of the possible longest paths.

5. Identifying vertices reachable in N steps

It is also possible to identify all vertices reachable in N steps from a given vertex using the function ego(). The first argument is the graph object. The second is the number of steps, and the third is the vertex of interest. The final argument is the direction - here we are interested in identifying all vertices reachable in 2 connections going outwards from F. G, E and A are all reachable in one step. Additionally, H is reachable in two steps via E. No other vertex can be reached in two outgoing steps from F.

6. Let's practice!

Time to put this into practice.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.