Access Millions of academic & study documents

dataSet = read csv(Test csv)library(igraph) library(

Content type
User Generated
Showing Page:
1/6
dataSet = read.csv(\"Test.csv\")
library(\"igraph\")
library(\"plyr\")
##### Similarity
gD <- simplify(graph.data.frame(dataSet,
directed=FALSE))
plot(gD)
degAll <- degree(gD, v = V(gD), mode = \"all\")
# Calculate betweenness for all nodes
betAll <- betweenness(gD, v = V(gD), directed = FALSE) /
(((vcount(gD) - 1) * (vcount(gD)-2)) / 2)
betAll.norm <- (betAll - min(betAll))/(max(betAll) -
min(betAll))
rm(betAll)
# Calculate Dice similarities between all pairs of nodes
dsAll <- similarity.dice(gD, vids = V(gD), mode = \"all\")
This is producing a graph in which everything on the graph
is nodes.
For Example, my input data was:
![dataset](http://i.imgur.com/JtwXPsQ.png?1)
And my end goal is to create node size/betweenness to
show similarity between recipes and similarity between
users but as of right now it is doing a combination of both.
I wanted two separate graphs, one similarity graph by ID
one similarity graph by Recipe.
![graph](http://i.imgur.com/6d1swp6.png?1)

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/6
Solution
dataSet = read.csv(\"Test.csv\")
rm(list = ls())
# Load libraries
library(\"igraph\")
library(\"plyr\")
# Read a data set.
dataSet <- read.table(\"lesmis.txt\", header = FALSE, sep =
\"\\t\")
# Create a graph. Use simplify to ensure that there are no
duplicated edges or self-loops
gD <- simplify(graph.data.frame(dataSet,
directed=FALSE))
# Print number of nodes and edges
# vcount(gD)
# ecount(gD)
# Calculate some node properties and node similarities
that will be used to illustrate
# different plotting abilities
# Calculate degree for all nodes
degAll <- degree(gD, v = V(gD), mode = \"all\")

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/6

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 6 pages?
Access Now
Unformatted Attachment Preview
dataSet = read.csv(\"Test.csv\") library(\"igraph\") library(\"plyr\") ##### Similarity gD ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4