Igraph package in RStudio: design error for bipolar graphics

In an attempt to learn the nuts and bolts of social network theory in the igraph package in R, I created a basic toy example of a bipartite chart of terrorist attacks during one year of the Algerian Civil War. The tops are made up of terrorist criminals and targets, while the ribs represent which group attacked the target.

I can plot a general one-sided graph of this relationship (as well as basic network centrality analyzes), but I am having trouble generating a two-sided network projection.

In @ GaborCsardi's suggestion, I only uploaded the igraph package to the global environment to ensure that the packages sna

or networks

do not conflict with the commands for the igraph.

However, the problem persists:

 library(igraph)

 perpetrator <- c("Algerian Islamic Extremists", 
             "Salafist Group for Preaching and Fighting (GSPC)", 
             "Salafist Group for Preaching and Fighting (GSPC)", 
             "Algerian Islamic Extremists", 
             "Salafist Group for Preaching and Fighting (GSPC)", 
             "Muslim Extremists",
             "Armed Islamic Group (GIA)",
             "Armed Islamic Group (GIA)",
             "Armed Islamic Group (GIA)",
             "Muslim Militants")

 target <- c("Police", "Military", "Terrorists/Non-state Militia", "Police",
             "Military", "Private Citizens & Property", 
             "Private Citizens & Property", "Private Citizens & Property", 
             "Private Citizens & Property", "Private Citizens & Property")

 dat <- cbind(perpetrator, target)

 net <- graph.edgelist(as.matrix(dat)) 

 plot(net, main="Domestic Terrorism during the Algerian Civil War")

 V(net)$type <- FALSE

 V(net)$type[V(net)$name%in%dat$perpetrator] <- TRUE

 V(net)$type[V(net)$name%in%dat$target] <- TRUE

 bipartite.mapping(net)

 proj_net <- bipartite.projection(net, type=V(net)$type)

      

At this point RStudio throws the following error:

 Error in .Call("R_igraph_bipartite_projection", graph, types, as.integer(probe1),  :  
 At bipartite.c:198 : Non-bipartite edge found in bipartite projection, Invalid value

      

+1


source to share


1 answer


According to the documentation, bipartite.mapping(...)

decides whether the vertices of the network can be mapped to two types of vertices so that no vertices of the same type are connected.

If possible, the item $type

in the list returned bipartite.mapping(...)

determines which subnet each vertex belongs to (via TRUE

or FALSE

). Note that there are several ways for your graph to do this.

You seem to be trying to define your sub-series yourself. Although in general, sub-series are not necessarily dicotyledonous, when you do this, in your case they are. Therefore, you can simply use bipartite.projection(...)

to separate net

on the sub as follows:

V(net)$type <- FALSE
V(net)$type[V(net)$name%in%dat$perpetrator] <- TRUE
proj_net <- bipartite.projection(net)

      



proj_net

is now a list with two elements - subgraphs.

If you want to use it bipartite.mapping(...)

to identify subnets, do it like this:

V(net)$type <- bipartite.mapping(net)$type
proj_net <- bipartite.projection(net)
set.seed(123)  # for reproducible plot
plot(net,vertex.color=ifelse(V(net)$type,"green","red"))

      

This does not group all targets together with performers, but the red and green subnets are bipartite.

+1


source







All Articles