Skip to content

Using doubly-nested subgraphs without connected nodes does not render #69

@Sushisource

Description

@Sushisource

I have created a repro case for this. I would expect this to generate output roughly like:

digraph structs {
    subgraph cluster_branch {
        subgraph UnChained {
            inode
        }
    }
}

Instead the output is just an empty digraph. This test fails.

    test("Dot rendering with one node") {
      import scalax.collection.Graph
      import scalax.collection.io.dot._
      import scalax.collection.io.dot.implicits._
      import scalax.collection.GraphEdge.DiEdge
      val g = Graph[Int, DiEdge](1)
      val root = DotRootGraph(
        directed = true,
        id = Some("structs")
      )
      val branchDOT = DotSubGraph(root,
                                  "cluster_branch",
                                  attrList = List(DotAttr("label", "branch")))
      val cSubGraph = DotSubGraph(branchDOT, "cluster_chained", attrList =
        List(DotAttr("label", "Chained")))
      val iSubGraph = DotSubGraph(branchDOT, "cluster_unchained", attrList =
        List(DotAttr("label", "UnChained")))
      val dot = g.toDot(
        dotRoot = root,
        edgeTransformer = _.edge match {
          case _ =>
            Some((root, DotEdgeStmt("hi", "guys")))
        },
        cNodeTransformer = Some({ _ => Some((cSubGraph, DotNodeStmt("cnode"))) }),
        iNodeTransformer = Some({ _ => Some((iSubGraph, DotNodeStmt("inode"))) })
      )
      assert(dot.contains("inode"))
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions