/**
 * Created by istemi on 27.09.2016.
 */ export default class GraphUtilities { static createGraphHierarchy ( nodes ) { var tree = [ ] ; var mappedArr = { } ; for ( var i = 0 , len = nodes . length ; i < len ; i ++ ) { var arrElem = nodes [ i ] ; mappedArr [ arrElem . id ( ) ] = arrElem ; mappedArr [ arrElem . id ( ) ] . childNodes = [ ] ; } for ( var id in mappedArr ) { var mappedElem = mappedArr [ id ] ; if ( mappedElem . parent ( ) . length > 0 ) { mappedArr [ mappedElem . parent ( ) . id ( ) ] . childNodes . push ( mappedElem ) ; } else { tree . push ( mappedElem ) ; } } return tree ; } ; static createGraphHierarchyRealTime ( nodes ) { var tree = [ ] ; var mappedArr = { } ; for ( var i = 0 , len = nodes . length ; i < len ; i ++ ) { var arrElem = nodes [ i ] ; mappedArr [ arrElem . data . id ] = arrElem ; mappedArr [ arrElem . data . id ] . children = [ ] ; } for ( var id in mappedArr ) { var mappedElem = mappedArr [ id ] ; if ( mappedElem . data . parent != - 1 ) { mappedArr [ mappedElem . data . parent ] . children . push ( mappedElem ) ; } else { tree . push ( mappedElem ) ; } } return tree ; } ; }