elk icon indicating copy to clipboard operation
elk copied to clipboard

Self-loop Edge on Port performs the Edge routing inside the Node

Open BjBe82 opened this issue 5 years ago • 8 comments

If a edge is referencing the same port it is routed inside the Node. Not sure if this is intended if "elk.insideSelfLoops.activate" and "elk.insideSelfLoops.yo" is false.

selfLoopInsideNode

Json

{
  "id": "graph",
  "layoutOptions": {
    "elk.algorithm": "layered",
    "elk.direction": "RIGHT",
    "elk.edgeRouting": "POLYLINE",
    "elk.layered.mergeEdges": "false",
    "elk.nodeSize.constraints": "[PORTS, NODE_LABELS]",
    "elk.nodeLabels.placement": "[H_CENTER, V_TOP, INSIDE]",
    "elk.portLabels.placement": "OUTSIDE"
  },
  "children": [
    {
      "id": "7f963681-6578-c0ce-2c8e-7e3e41efa0cd_block",
      "children": [],
      "edges": [],
      "labels": [{ "id": "7f963681-6578-c0ce-2c8e-7e3e41efa0cd_block_label", "text": "A", "x": 5, "y": 5, "width": 114.203125, "height": 16 }],
      "ports": [
        {
          "id": "59af73cb-119a-c65e-6390-ba56cbfd0d53",
          "labels": [{ "id": "853b4ae3-6b3e-771f-7412-e2ed36753744", "text": "aa:AA", "x": -5.734375, "y": 1, "width": 22.46875, "height": 9 }],
          "width": 11,
          "height": 11
        }
      ],
      "x": 12,
      "y": 22,
      "width": 124.203125,
      "height": 49
    },
    {
      "id": "eb4d1e26-b35a-9736-1a1b-5e2fae38b687_block",
      "children": [],
      "edges": [],
      "labels": [{ "id": "eb4d1e26-b35a-9736-1a1b-5e2fae38b687_block_label", "text": "B", "x": 5, "y": 5, "width": 114.203125, "height": 16 }],
      "ports": [
        {
          "id": "000a7ee5-e679-6b93-9ec7-f2439b6b0454",
          "labels": [{ "id": "a464e361-6927-0a3f-289d-6f0a45d3f90d", "text": "bb:BB", "x": -5.734375, "y": 1, "width": 22.46875, "height": 9 }],
          "width": 11,
          "height": 11
        },
        {
          "id": "759f91c4-f7bd-470b-1539-22b24774cf70",
          "labels": [{ "id": "0a7ee8df-e925-86ff-9610-195d43039fd1", "text": "loop:Loop", "x": -12.3515625, "y": 1, "width": 35.703125, "height": 9 }],
          "width": 11,
          "height": 11
        }
      ],
      "x": 156.203125,
      "y": 22,
      "width": 124.203125,
      "height": 49
    }
  ],
  "edges": [
    {
      "id": "00d672ab-6bf3-29b0-b3d6-b00e0e50d2bb_edge",
      "source": "7f963681-6578-c0ce-2c8e-7e3e41efa0cd_block",
      "sourcePort": "59af73cb-119a-c65e-6390-ba56cbfd0d53",
      "target": "eb4d1e26-b35a-9736-1a1b-5e2fae38b687_block",
      "targetPort": "000a7ee5-e679-6b93-9ec7-f2439b6b0454"
    },
    {
      "id": "02396688-b069-7922-376e-4161e878d73c_edge",
      "source": "eb4d1e26-b35a-9736-1a1b-5e2fae38b687_block",
      "sourcePort": "759f91c4-f7bd-470b-1539-22b24774cf70",
      "target": "eb4d1e26-b35a-9736-1a1b-5e2fae38b687_block",
      "targetPort": "759f91c4-f7bd-470b-1539-22b24774cf70"
    }
  ]
}

BjBe82 avatar Mar 30 '20 11:03 BjBe82

We currently do not support such edges in ELK Layered. I'll classify this as an enhancement, but I have a hunch that implementing this would not be that easy. So please don't hold your breath. ;)

le-cds avatar Mar 31 '20 10:03 le-cds

Thanks for the quick answer ;) . So maybe we will think about some post processing for such edges or live with it for the moment.

BjBe82 avatar Mar 31 '20 11:03 BjBe82

@le-cds I'd suggest to report the issue back to the user (i.e. an edge with the same source and target port) as an invalid graph configuration exception, or the like.

uruuru avatar Mar 31 '20 15:03 uruuru

@uruuru Usually, I would agree, but given that @BjBe82 may choose to ignore the issue for the time being, I wouldn't want to force him to exclude the edge from layout and then post-process it. However, if you, @BjBe82, choose to post-process the edge, I'd follow the suggestion by @uruuru.

le-cds avatar Mar 31 '20 15:03 le-cds

The picture and json above is only an example … the graph is based on some engineering data which should be visualized i.e. for a review. I was not questioning the engineering data at this point and only observed the edge which could be routed outside of the node.

Since I am not an ELK expert, I only want to make sure that I was not doing something wrong (which could be easily solved by some options).

I need to check with the enduser how he wants to deal with it. :)

BjBe82 avatar Mar 31 '20 17:03 BjBe82

@le-cds I was aiming in the direction of notifying the user that the graph as provided is actually not supported by the layout algorithm. Another option would be to discard such edges during layout in order to at least not produce weird results.

There are several ways to handle this and so far we've usually not really bothered telling the user if something fails silently :).

The best way (imho) would be to discard the edges during layout but notify the user with a warning. However, there's no means to do so in our current architecture.

uruuru avatar Mar 31 '20 18:03 uruuru

I need to check with the enduser how he wants to deal with it. :)

We'll be here waiting for the reply. 😉

I was aiming in the direction of notifying the user that the graph as provided is actually not supported by the layout algorithm.

Ah, I see. Yeah, warnings of some sort sound sensible. We'd need a proper strategy of when to throw exceptions and when to just trigger warnings, though.

le-cds avatar Apr 01 '20 12:04 le-cds

I guess currently, we would rather from an UnsupportedGraphException and report the problem.

soerendomroes avatar Mar 15 '22 11:03 soerendomroes

With ELK 0.6.0 this was fixed to look like this.

Screenshot from 2022-11-15 16-56-09

@BjBe82 Would you rather have as report the problem or is this self-loop sufficient?

soerendomroes avatar Nov 15 '22 15:11 soerendomroes

From my point of view, the self-loop is sufficient. I think the layout algorithm should only report problems if it has trouble to layout something which is not supported.

Anything else is more or less on the semantic level and depends on the underlying data and will be covered (at least in our case) by consistency checks. Where the result is then shown as decorators on the edge, for example.

BjBe82 avatar Nov 17 '22 08:11 BjBe82