Difference between revisions of "Social Network Analysis With Igraph Package Using R"

From AIRWiki
Jump to: navigation, search
(New page: = Install the package under R environmemnt = type the command: <code>install.packages("igraph")</code> = Starting with the package = don't forget to load the library: <code>library('i...)
 
(Starting with the package)
Line 10: Line 10:
 
parse a network file in Pajek format and access to its memory representation through the variable 'g':
 
parse a network file in Pajek format and access to its memory representation through the variable 'g':
 
  <code>g <- read.graph(file='/your/path/.../file.net', format='pajek')</code>
 
  <code>g <- read.graph(file='/your/path/.../file.net', format='pajek')</code>
 
+
list vertex and their attributes of graph g:
 +
<code>
 +
V(g) # the list of all nodes
 +
V(g)[0] # access the first node
 +
list.vertex.attributes(g) # the list of all vertex attributes names
 +
V(g)[0]$id # access the attribute 'id' for the first node
 +
</code>
  
  
  
 
[[Category:Tutorial]]
 
[[Category:Tutorial]]

Revision as of 12:21, 3 April 2010

Install the package under R environmemnt

type the command:

install.packages("igraph")


Starting with the package

don't forget to load the library:

library('igraph')

parse a network file in Pajek format and access to its memory representation through the variable 'g':

g <- read.graph(file='/your/path/.../file.net', format='pajek')

list vertex and their attributes of graph g:


V(g) # the list of all nodes
V(g)[0] # access the first node
list.vertex.attributes(g) # the list of all vertex attributes names
V(g)[0]$id # access the attribute 'id' for the first node