"use strict" ; import { EdgeImmutPlain } from "../classes/GraphImmut/EdgeImmut" ; import { NodeImmutPlain } from "../classes/GraphImmut/NodeImmut" ; interface Degree { in : number ; out : number ; } export default { findVertexDegreesDirectional : ( adjacencyMatrix ) : Degree [ ] => { const degrees = [ ] ; adjacencyMatrix . forEach ( ( v , i ) => { if ( i in degrees ) { degrees [ i ] . out += v . length ; } else { degrees [ i ] = { out : v . length , in : 0 } ; } v . forEach ( ( outV ) => { if ( outV in degrees ) { degrees [ outV ] . in += 1 ; } else { degrees [ outV ] = { in : 1 , out : 0 } ; } } ) ; } ) ; return degrees ; } , interpolateNodesFromEdges : ( edges ) : NodeImmutPlain [ ] => { const nodes = [ ] ; edges . forEach ( ( v ) => { nodes [ v . from ] = { id : v . from , label : v . from . toString ( ) } ; nodes [ v . to ] = { id : v . to , label : v . to . toString ( ) } ; } ) ; return nodes ; } , } ;