Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-gojs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴斌
vue-gojs
Commits
0c3502c8
Commit
0c3502c8
authored
Oct 24, 2023
by
吴斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:路径寻找
parent
112d3fb3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
App.vue
src/App.vue
+0
-0
GOJSKit.ts
src/kit/GOJSKit.ts
+7
-6
No files found.
src/App.vue
View file @
0c3502c8
This diff is collapsed.
Click to expand it.
src/kit/GOJSKit.ts
View file @
0c3502c8
...
...
@@ -16,6 +16,7 @@ export function getMapData(myDiagram:any) {
})
linkDataArray
.
forEach
((
item
:
any
)
=>
{
let
node
=
null
;
// 只记录双向连接
if
(
item
.
from
&&
item
.
to
){
node
=
nodeMap
[
item
.
from
]
node
.
next
.
push
(
item
.
to
)
...
...
@@ -57,12 +58,12 @@ export function findNodesAllWayBetween(startKey:number, endKey:number, myDiagram
while
(
!
flag
){
// 保存当前路径的节点数量
let
beforePathsNode
=
0
;
let
beforePathsNode
Count
=
0
;
// 保存扩展后路径的节点数量
let
afterPathsNode
=
0
;
let
afterPathsNode
Count
=
0
;
// 计算扩展前的总路径节点数量
for
(
let
path
of
paths
){
beforePathsNode
+=
path
.
length
beforePathsNode
Count
+=
path
.
length
}
for
(
let
path
of
paths
){
// 获取当前路径的最后一个节点
...
...
@@ -85,7 +86,7 @@ export function findNodesAllWayBetween(startKey:number, endKey:number, myDiagram
else
{
for
(
let
nextNodeKey
of
nextNode
){
// 如果下一个节点已经在路径中,则跳过,无需扩展,避免循环
if
(
nextNodeKey
in
path
){
if
(
path
.
indexOf
(
nextNodeKey
)
!==
-
1
){
continue
}
let
newPath
=
path
.
slice
(
0
)
...
...
@@ -99,10 +100,10 @@ export function findNodesAllWayBetween(startKey:number, endKey:number, myDiagram
}
// 计算扩展后的总路径节点数量
for
(
let
path
of
paths
){
afterPathsNode
+=
path
.
length
afterPathsNode
Count
+=
path
.
length
}
// 如果paths内元素数量没有增加,则搜索完成
if
(
beforePathsNode
==
afterPathsNode
){
if
(
beforePathsNode
Count
==
afterPathsNodeCount
){
flag
=
true
// 删除没有找到终点的路径
paths
=
paths
.
filter
((
item
:
any
)
=>
item
[
item
.
length
-
1
]
==
endKey
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment