Skip to content

Layouts of graphs with multiple components #80

@thchr

Description

@thchr

Several of the layout algorithms produce not-very-useful layouts if the input graph is not connected, i.e., has more than one connected component.

For example:

using GLMakie, GraphMakie, Graphs
g = wheel_graph(4)
es = collect(edges(g))
g2 = Graph(vcat(es, [Edge(e.src + nv(g), e.dst + nv(g)) for e in es])) # make two unconnected copies of `g`
graphplot(g2; layout=Spring())

Produces:

Which has at least two issues:

  1. The two graphs are seemingly unnecessarily far apart.
  2. The layout of each individual component is worse than it would be for a single component (compare with graphplot(g, layout=Spring()) below):

From testing, Stress, Spectral, and especially SFDP have this issue. Stress probably also has the issue, but it is less pronounced. E.g., here's graphplot(g2; layout=SFDP()):

I think it would make sense to apply these layout algorithms on the connected components of a graph individually, and then somehow layout their components subsequently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions