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

1 answer below »
Subject is called social media intelligence and the work has got to do with R programming


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 graph). 2. Compute and report the diameter and density of the graph. 3. Plot the degree distribution of the graph and estimate the Power 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 DayDec 19, 2022

Answer To: Write R code to do the following:1. Generate and plot a random undirected power law graph with 30...

Mukesh answered on Dec 19 2022
49 Votes
Write R code to do the following:
1. Generate and plot a random undirected power law graph with 30 n
odes
and power 1.2 (use the function barabasi.game from the igraph
library 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 Power
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