**Warning**: Parameter 2 to wp_hide_post_Public::query_posts_join() expected to be a reference, value given in

**/home/rexercis/public_html/wp-includes/class-wp-hook.php**on line

**286**

Difficulty level:

Following on from last time, this tutorial will focus on more advanced graph techniques and existing algorithms such as Dijkstra’s algorithm that can be used to draw real meaning from graphs.

This is part 2 in the series of iGraph tutorials, for part 1, click here.

When completing these tutorials be sure to read up on the algorithms you are implementing; Wikipedia is usually a good place to start. In practice, when the graphs are much larger in size, complete solutions to these problems are not possible and instead, we seek the closest approximation.

Solutions are available here.

**Exercise 1**

Copy the following code into your R script to generate data for a bipartite graph.

—

matches <- data.frame(name = rep(c(“Jerry”, “Lilly”, “Karl”, “Jenny”), each = 4),

subject = rep(c(“Maths”, “English”, “Biology”, “French”), 4),

weight = c(81, 78, 24, 58, 76, 60, 62, 83, 35, 59, 50, 56, 72, 90, 88, 86))

g <- graph_from_data_frame(matches, directed = FALSE)

—

From this, assign each set of nodes a unique type, 1 or 2

**Exercise 2**

Now plot your graph, clearly showing the two sides to the bipartite graph.

**Exercise 3**

Determine the minimum colouring needed so that no two adjacent vertices are the same colour

**Exercise 4**

Algorithmically, find the best matching between student and subject based upon their respective mark in each subject.

**Exercise 5**

Add three additional nodes to your graph for Becky, Ben and Mark. Connect these up to Maths, French and Biology respectively.

**Exercise 6**

Calculate a spectrum or adjacency matrix for your new graph.

**Exercise 7**

Plot your eigenvalues and visually determine the rank of your adjacency matrix.

**Exercise 8**

Find the size of independent vertex set. What does number mean?

**Exercise 9**

Calculate the k, such that the graph is k-vertex connected

**Exercise 10**

Calculate the k, such that the graph is k-edge connected

**What's next:**

- Become a Top R Programmer Fast with our Individual Coaching Program
- Explore all our (>4000) R exercises
- Find an R course using our R Course Finder directory
- Subscribe to receive weekly updates and bonus sets by email
- Share with your friends and colleagues using the buttons below

## Leave a Reply