Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Detect if Node is child or parent (Read 2132 times)
mark korn
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Dec 2nd, 2009
Detect if Node is child or parent
Feb 19th, 2010 at 3:46pm
Print Post  
Hi, can you help me with this?
onLinkCreated,i have this function which check if the LinkDestination is parent(grandparent,grand-grandparent ,it doesn't matter,i don't want an infinite cicle between some nodes) for LinkOrigin.The problem is when I have more brothers and sisters on some level,and i can't figure it out how to solve this.

var isChild;
var counter = 0;
function checkChild(origin,destination)
{
var applet = <%=diagramView.AppletElement%>;
var diagram = applet.getDiagram();
var diagramNodes = diagram.getNodes().size();



var destinationChild= destinatie.getOutgoingLinks().size();
//base
if (counter> diagramNodes) { isChild= 0;counter= 0;}
if (origin.getTag() == destinatie.getTag()) {isChild= 1; return(isChild;)};
if (destinationChild == 0) {isChild= 0;}


//recursion
else for (i = 0;i < destinationChild;++i)
{
if (isChild== 1)
break;
var linkT = destination.getOutgoingLinks().get(i);
checkCopil(origin,linkT.getDestination());
counter++;

}

}
return (isChild);


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Detect if Node is child or parent
Reply #1 - Feb 19th, 2010 at 3:57pm
Print Post  
Hi,

Call ScriptHelper.createPathFinder() to get a PathFinder instance, and then call the finder.findShortestPath(dest, origin) method.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint