Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Incorrect access to node indices inside LayoutEngine::setupHierarchicalLayout (?) #4228

@softwareCobbler

Description

@softwareCobbler

I think I found a small bug inside vis/lib/network/modules/LayoutEngine.js. In the file in the master branch, LayoutEngine.js line 713 reads:

for (nodeId in this.body.nodes) {

But this.body.nodes contains nodes and edges (see breakpoint screencap).

This bug becomes apparent when nodes have user-assigned levels, and the configurator toggles back and forth between hierarchical layout and "normal" layout (which calls setupHierarchicalLayout) . When nodes have levels, the edges in this.body.nodes most certainly do not (why would they?), and the program complains that To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.

The fix I have minimally tested is a small change to line 713 to read:

for (nodeId of this.body.nodeIndices) {

which ensures we lookup nodes by only node keys.

I think it is rare for a user to toggle back and forth between hierarchical and "normal" layouts, but with the configurator it is possible. See pull request #4183 for (as of this writing) a broken version of toggling back and forth between a hierarchical layout and a normal layout, once levels have been assigned to nodes.

Any thoughts?

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