Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Write R code to do the following: 1. Generate and plot a random undirected power law graph with 30 nodes and power 1.2 (use the function barabasi.game from the igraph library to generate the...

1 answer below »
Write R code to do the following:
1. Generate and plot a random undirected power law graph with 30 nodes
and power 1.2 (use the function barabasi.game from the igraph
li
ary to generate the graph).
2. Compute and report the diameter and density of the graph.
3. Plot the degree distribution of the graph and estimate the Powe
Law coefficient from the degree distribution.
4. Describe the how the random power law graph is created and explain
what the power coefficient reveals about the graph.
Answered Same Day Dec 19, 2022

Solution

Mukesh answered on Dec 19 2022
38 Votes
Write R code to do the following:
1. Generate and plot a random undirected power law graph with 30 nodes
and power 1.2 (use the function barabasi.game from the igraph
li
ary to generate the graph).
Code
# Generate and plot the random undirected power law graph with 30 nodes
# and power 1.2
set.seed(123) # Set the seed for reproducibility
g <- barabasi.game(30, power = 1.2, directed = FALSE)
plot(g, layout=layout.fruchterman.reingold)
Output
    
2. Compute and report the diameter and density of the graph.
Code
# Compute and report the diameter and density of the graph
diameter <- diameter(g)
density <- graph.density(g)
print(paste("The diameter of the graph is", diameter))
print(paste("The density of the graph is", density))
Output-
    [1] "The diameter of the graph is 10"
    [1] "The density of the graph is 0.0666666666666667"
3. Plot the degree distribution of the graph and estimate the Powe
Law coefficient from the degree distribution.
Code
# Plot the degree distribution of...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here