Extract nodes to edge token calculation logic