Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

Categories

edge labels at source and destination

0 votes

Hello! I am generating a graphml file with a python script and I'm reading it with yEd. I'm assigning 2 labels to all the edges. One label is called source and the other destination. These labels represent the "source interface" and the "destination interface" in a network topology. So far I'm able to display labels using "Properties Mapper". I'm having issues assigning the edge labels to the beginning of the line and to the end. So far I've tried different layouts for labels but I don't get the expected result, I think the closest algorithm is "side slider" but it's not always accurate. I would do this manually but my network topology will have a lot of nodes and I want to automate this. My question is: Is there any way to specifically assign these labels to the start and the end of the line? Just like the image:

in Help by (130 points)
edited by

1 Answer

+1 vote

Yes, there is a way to place labels close to the start or end node of an edge. Property "Placement" determines the position of a label. Instead of using the default value "SmartFree: Anywhere" use "6 Pos: Source Head" to place a label close to the start node or "6 Pos: Target Head" to place a label close to the end node.

If you plan to modify you python script to generate GraphML files with appropriate label definition right from the start, I suggest creating a trivial diagram with only two nodes, one edge, and two edge labels (one with placement "6 Pos: Source Head" and one with placement "6 Pos: Target Head"), saving the diagram as GraphML, and inspecting the resulting file for the required XML elements. Look for <y:EdgeLabel> elements, the important attributes are modelName and modelPosition:

  <y:EdgeLabel ... modelName="six_pos" modelPosition="shead">
    ...
  </y:EdgeLabel>

  <y:EdgeLabel ... modelName="six_pos" modelPosition="thead">
    ...
  </y:EdgeLabel>


If you prefer to stick to using properties mapper instead of modifying the script, you can use the following approach:

  1. Create a user-defined palette section (see section Palette Manager  in the yEd manual for documentation on creating palette sections).
  2. Create an edge with two labels as mentioned above (i.e. one label with placement "6 Pos: Source Head" and another one with placement "6 Pos: Target Head").
  3. Right-click the edge to open its context menu and choose "Add to Palette".
  4. In your properties mapper edge configuration choose "Template: Single" and select the palette template corresponding to the edge from step 2.
  5. Map your source and destination properties to labels #1 and #2.
by [yWorks] (160k points)
Thanks for the information! I used properties mapper and it works great.
Legal Disclosure | Privacy Policy
...