Skip to content

A leaf node can never be a left child unless its a sibling of another leaf node #5

@ravicious

Description

@ravicious

Petgraph doesn't have any notion of "left" and "right" because it's not a library for binary trees but rather a general purpose graph library. Because of that, whatever node gets added as a child first ends up being the left child.

Now, we always create internal nodes first and then fill out remaining space with leaf nodes. As a result of that, a leaf node will never be a left child, unless its a sibling of another leaf node.

This is a problem because we might be missing out on better layouts.

Blueprints don't store leaf nodes, so with blueprints it's not even possible to express a leaf node being a left child.

To fix this problem:

  • Blueprints need to have a concept of leaf nodes.
  • When adding a leaf node to a node with one child already there, there should be a 50% chance for swapping the order of the children.
  • Layout crossover should still work with leaf nodes on the left – this requires the blueprint change from the first point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions