Skip to content

Is it possible to force edge length to be 0, permanently? #475

Description

@salk-law

Is it possible to make edges lengths zero such that two nodes are immediately adjacent, and this arrangement is maintained while moving nodes? I'm imagining clicking and dragging one node and the node with which is shares an edge of zero length moves with it. Is this possible, and if so, how can it be done?

I tried setting length to zero but it doesn't seem to have any effect:

# Reproducible example of problem
library(visNetwork)
library(data.table)
library(magrittr)
# For reproducibility
set.seed(1)

# Declare nodes
nodes = data.table(
  id = letters[1:10], 
  label = letters[1:10]
)

# Declare edges
edges = data.table(
  from = sample(letters[1:10], 10, replace = T), 
  to = sample(letters[1:10], 10, replace = T),
  color = "blue",
  dashes = T,
  length = 200
)

# Add duplicate edges
edges.dupl = edges[rep(1:3, 1)][, `:=`(color = "red", dashes = F, length = 0)]
edges = rbind(edges.dupl, edges)

# Render graph
visNetwork(nodes = nodes, edges = edges) %>%
  visNodes(physics = F) %>%
  visEdges(physics = F)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions