Skip to content

Flip node/edge behavior #169

Answered by agila5
apeterson91 asked this question in Q&A
Aug 27, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi @apeterson91! I think you are looking for the to_linegraph morpher to convert your graph into its Line graph. See also our vignette on morphers and ?igraph::line_graph.

For example, we can create a super simple spatial network with 3 vertices and 2 edges:

# packages
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(sfnetworks)

# data
my_sfc <- st_sfc(
  st_linestring(rbind(c(-1, 0), c(0, 0))), 
  st_linestring(rbind(c(0, 0), c(0, 1)))
)

# create sfnetwork
my_sfn <- as_sfnetwork(my_sfc, directed = FALSE)
par(mar = rep(0, 4))
plot(my_sfn)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@apeterson91
Comment options

@apeterson91
Comment options

Answer selected by agila5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants