|Guidance on invoking AllCrossingsCounter [message #1858257]
||Sat, 25 March 2023 03:47
| Michael Lynott
Registered: September 2021
Added Sun 3/26 US MDT|
By reviewing the code of the classes that use IInitializer I learned how to create a set of IInitializables, and then initialize the relevant class. In so doing,
I answered all the questions I posed in the original post.
I discovered that the approach I outlined below is not appropriate to accomplish my goal. I am writing a crossing-checker for my final graph that does not depend on levels. I examine instead the set of y-positions of the vertices, and create level-equivalents from that set of values instead.
It would have been useful to show an example of how to begin working with one of the IInitializable classes. These are the steps I took to attempt that. Please let me know whether this is appropriate, so others can see it (or your corrected version). Thanks.
Begin code snippet for using a class that implements IInitializable
* "lg" is my "L-Graph".
* Find the node array that AllCrossingsCounter needs as input
LNode currentOrder = lg.toNodeArray();
* Instantiate crossingsCounter: a new AllCrossingsCounter
AllCrossingsCounter crossingsCounter =
* Create a list (using Google Guava "Lists" Collection)
* of one element, crossingsCounter.
List<IInitializable> initializables =
* I-Initialize crossingsCounter
/* or crossingsCounter.init(initializables, currentOrder): */ ??
End code snippet for using a class that implements IInitializable.
Original message below:
I'm building a tool to draw a specific kind of diagram.
My goal with this code is to count line crossings of the final graph.
The approach I outline below is time-consuming, but that's okay.
I'm trying to minimize the amount of code I write for this exercise.
Here is my approach:
Create a "K-graph" and process it with the Layered option
Because I want to use existing code as much as possible, I found AllCrossingsCounter so I did the following:
ElkGraphTransformer egt = new ElkGraphTransformer();
lg = egt.importGraph(graphIn); # graphIn is a "K-graph"
I want to invoke AllCrossingsCounter so I retrieve "nodeOrder"
final LNode nodeOrder = lg.toNodeArray();
Then I get the list of Layers, as the other "init" parameter for AllCrossingsCounter
List<Layer> LayerList = lg.getLayers();
I attempted to do the following (which fails):
1. Is this a sensible approach to finding crossings in the final graph? I could just reproduce a cross-counting algorithm I learned elsewhere but that would require me to write and test more code.
2. How should I assemble the List that is needed as the first parameter to AllCrossingsCounter?
3. How should I invoke AllCrossingsCounter.init correctly?
Thank you for your help. And thank you for version 0.8.1.
[Updated on: Mon, 27 March 2023 03:59]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01943 seconds