@name Node Graph converter
@inputs Graph:wirelink
@outputs Nodes2:table C Count Count2
@persist [Filename Co Brk]:string
@trigger
@model models/props_junk/PopCan01a.mdl
if(first()){
    Nodes=table()
    Nodes2=table()
    C=1
    Filename="nodegraphs/Nodegraph_5_"+map()+".txt"
    Co=":" #Colon, this is a link pair divider
    Brk="<" 
} 
Nodes=Graph["Nodes",table]

Count=round(Nodes:count()/2)
Count2=Nodes2:count()
if(Count!=Nodes2:count()){
    
    if(C<=Count){timer("keep going",10)}
    while(C<=Count&perf()){
        CS=toString(C)
        Vec=Nodes[CS,vector]
        Str=Nodes["S"+CS,string]
        Links=array()
        Links=Str:replace(CS+Co,""):explode(Brk) #This converts the Link from string format to an array of strings
        #Nodes2[C,array]=array()
        Nodes2[C,array]=array(Vec)
        Linx=array()
        for(D=1,Links:count()){
            if(Links[D,string]!="0"){
                Nodes2[C,array]:pushNumber(Links[D,string]:toNumber())
            }
            if((D==2)&Nodes2[C,array][D,number]!=C){Nodes2[C,array]:insertNumber(2,C)}
        }
        print(C+"/"+Count)
        C++
    }
    if(C>Count){
        print("Saving "+Nodes2:count()+" Nodes to "+Filename)
        fileWrite(Filename,glonEncode(Nodes2))
    }
    
}

#Version 5 format = Nodes[number,array]array(vector,self,link1,link2,etc..)
