BaşlayınÜcretsiz Başlayın

Directed igraph objects

In this exercise you will learn how to create a directed graph from a dataframe, how to inspect whether a graph object is directed and/or weighted and how to extract those vertices at the beginning and end of directed edges.

Bu egzersiz

Network Analysis in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Convert the dataframe measles into an igraph graph object using the function graph_from_data_frame() and ensure that it will be a directed graph by setting the second argument to TRUE.
  • Check if the graph object is directed by using is.directed().
  • Examine whether the edges of the graph object are already weighted by using is.weighted().
  • Subset each vertex from which each edge originates by using head_of(). This function takes two arguments, the first being the graph object and the second the edges to examine. For all edges you can use E(g).

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

library(igraph)

# Get the graph object
g <- ___(measles, directed = ___)

# is the graph directed?
___(g)

# Is the graph weighted?
___(g)

# Where does each edge originate from?
table(___(___, E(g)))
Kodu Düzenle ve Çalıştır