Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EMF-IncQuery » Extract transitive closure path from match
Extract transitive closure path from match [message #1653781] Fri, 06 March 2015 11:30 Go to next message
Nasuki Matamoto is currently offline Nasuki MatamotoFriend
Messages: 27
Registered: November 2014
Junior Member
Hello!

For validation purposes I check wether algebraic loops are present within the model using transitive closoure ( linksTo+(A,A) )

How do I use the getPathFinder/TransitiveClosureHelper to get a path (which should be a loop) from A to itself within an MatchProcessor?

I want to show the path to the user so he can tear it up

Regards,

[Updated on: Fri, 06 March 2015 11:32]

Report message to a moderator

Re: Extract transitive closure path from match [message #1656020 is a reply to message #1653781] Sat, 07 March 2015 09:54 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 342
Registered: July 2015
Senior Member
Hi,

I tried to collect the required steps to use TransitiveClosureHelper. My description will use the API from 0.9.0 (the relevant APIs have changed a bit in 0.9.0, so for older versions the description here will need to be adapted).

First of all, I would not want to initialize a TransitiveClosureHelper inside an IMatchProcessor; more specifically, I would create a single instance and reuse it between different executions of the match processor. As the helper is also incremental, this would be safe.

I was not the original developer, so I am not 100% sure about this, but as far as I understood, this feature only works for the transitive closure of EReferences, not on the transitive closure of patterns. For EReferences, consider the following snippet for initializing the pathFinder; and then share it with your match processor.

IncQueryEngine engine = ...; //Use any IncQueryEngine over any EMF model
Set<EReference> eReferenceSet = ...; //Create a set of EReferences you have to consider for the transitive closure
NavigationHelper baseIndex = EMFScope.getUnderlyingEMFIndex(engine);
TransitiveClosureHelper tcHelper = IncQueryBaseFactory.createTransitiveClosureHelper(baseIndex, eReferenceSet);
final IGraphPathFinder<EObject> pathFinder = tcHelper.getPathFinder(); //you can share this instance with your matchprocessor instance


I hope, this was helpful. If not, feel free to ask for clarifications.

Cheers,
Zoltán
Re: Extract transitive closure path from match [message #1658522 is a reply to message #1656020] Sun, 08 March 2015 11:26 Go to previous messageGo to next message
Nasuki Matamoto is currently offline Nasuki MatamotoFriend
Messages: 27
Registered: November 2014
Junior Member
Thank you! Yes I'm only interested in the actual objects wich form a link.

Just two questions:

Algebraic loops only form cycles with stateless functions. Now,
I have also stateful functions, which terminate a cycle, so only algebraic ones (which are errors) are matched.

Did I understand you correctly that the helper class will return any path (let's say two cycles are present: algebraic A -B - C - A and stateful A - B - *S* - C - A)

So I would get both paths and have to do the filtering myself?

2nd Question: The helper is incremental -> Inside the cycle processor, can i simply add the variable to the reference set and retrieve the path? Because in your snippet you set the reference set globally and just share the helper with the processor ...

Otherwise I would have the paradoxical situation:
I want to retrieve the cycle -> I have to set the start/end (referenceSet) of the cycle before I know that a cycle exists!

Regards,

[Updated on: Sun, 08 March 2015 11:30]

Report message to a moderator

Re: Extract transitive closure path from match [message #1660699 is a reply to message #1658522] Mon, 09 March 2015 09:46 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 342
Registered: July 2015
Senior Member
Hi,

1) Yes, it should return all paths; or an unspecified path if you request only a single one.

2) By incremental behavior I meant, if the model is updated, the internal data structures of the Transitive Closure Helper are as well, so if you add an element/edge to the model after that you can ask for the available paths, it should work.

Cheers,
Zoltán
Re: Extract transitive closure path from match [message #1661102 is a reply to message #1660699] Mon, 09 March 2015 13:34 Go to previous message
Nasuki Matamoto is currently offline Nasuki MatamotoFriend
Messages: 27
Registered: November 2014
Junior Member
Ok, thank you very much!

I just noticed that my previous question arose from a misunderstanding on my part

Cheers!
Previous Topic:Migration to 0.9.0 documentation?
Next Topic:IncQuery for RCP Applications
Goto Forum:
  


Current Time: Fri Sep 21 11:46:56 GMT 2018

Powered by FUDForum. Page generated in 0.01927 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top