import { Set } from 'immutable' ; import { State , Id } from '../customTypings/index.d' ; param state param nodeId param predecessors export function getPredecessors ( state , nodeId , predecessors ? ) { return state . getIn ( [ 'parents' , nodeId ] ) . reduce ( ( accumulator , parentId ) => getPredecessors ( state , parentId , accumulator ) . add ( parentId ) , predecessors || Set ( ) ) ; } param state param nodeId param successors export function getSuccessors ( state , nodeId , successors ? ) { return state . getIn ( [ 'childrens' , nodeId ] ) . reduce ( ( accumulator , childrenId ) => getSuccessors ( state , childrenId , accumulator ) . add ( childrenId ) , successors || Set ( ) ) ; }