'Removing arrows and make the line hearver igraph

In this graph:

The input data are:

df <- structure(list(book1 = structure(1:4, .Label = c("refid1", "refid2", 
"refid3", "refid7"), class = "factor"), book2 = structure(c(2L, 
3L, 3L, 1L), .Label = c("", "refid1", "refid3"), class = "factor"), 
    book3 = structure(c(2L, 3L, 4L, 1L), .Label = c("", "refid1", 
    "refid2", "refid4"), class = "factor"), book4 = structure(c(2L, 
    3L, 4L, 1L), .Label = c("", "refid1", "refid3", "refid4"), class = "factor"), 
    book5 = structure(c(2L, 3L, 3L, 1L), .Label = c("", "refid2", 
    "refid6"), class = "factor"), book6 = structure(c(3L, 2L, 
    1L, 1L), .Label = c("", "refid1", "refid2"), class = "factor"), 
    book7 = structure(c(2L, 3L, 1L, 1L), .Label = c("", "refid1", 
    "refid5"), class = "factor")), .Names = c("book1", "book2", 
"book3", "book4", "book5", "book6", "book7"), class = "data.frame", row.names = c(NA, 
-4L))

and the graph plot comes from this:

library(dplyr)
library(igraph)
library(tidyr)


g<- df %>% 
  gather(key = "From", "To", na.rm = TRUE) %>% 
  graph_from_data_frame()

plot(g)

How is it possible to remove the arrows of the graph and have just simple lines?

r


Solution 1:[1]

If you already have a graph (that you could have imported via another method that doesn't support directed=FALSE or that you want to be directed but you just don't want to _ plot_ the arrows) you can also do:


    g<- df %>% 
      gather(key = "From", "To", na.rm = TRUE) %>% 
      distinct(From,To) %>% 
      graph_from_data_frame()
    E(g)$arrow.mode="-" #or whatever symbol that is not in c("<", "<-",">",">",“<>”,“<->)
    plot(g)

As stated in the documentation this allows to create directed graph with mixed style edges representation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simon C.