Mulai sekarangMulai gratis

Counting vertices and edges

A lot of basic information about a network can be extracted from an igraph object. In this exercise you will learn how to count the vertices and edges from a network by applying several functions to the graph object g.

Each row of the friends dataframe represents an edge in the network.

Latihan ini merupakan bagian dari kursus

Network Analysis in R

Lihat Kursus

Instruksi latihan

  • Use V() and E() to view the vertices and edges respectively of the network.
  • Use gsize() to count the number of edges in a network.
  • Use gorder() to count the number of vertices in a network.

Latihan interaktif langsung praktik

Cobalah latihan ini dengan melengkapi kode contoh ini.

# Load igraph
library(igraph)

# Subset vertices and edges
V(___)
E(___)

# Count number of edges
gsize(___)

# Count number of vertices
____(g)

Edit dan Jalankan Kode