Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rictjo
impetuous
提交
965f4d18
I
impetuous
项目概览
rictjo
/
impetuous
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
impetuous
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
965f4d18
编写于
11月 23, 2021
作者:
rictjo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dag search++
上级
fd67668a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
4 deletion
+30
-4
src/impetuous/convert.py
src/impetuous/convert.py
+30
-4
未找到文件。
src/impetuous/convert.py
浏览文件 @
965f4d18
...
...
@@ -176,7 +176,10 @@ class NodeGraph ( Node ) :
results
[
'path'
]
=
[
idx
for
idx
in
results
[
'path'
]
if
not
idx
==
identification
]
return
(
results
)
def
search
(
self
,
order
:
str
=
'breadth'
,
root_id
:
str
=
None
,
linktype
:
str
=
'links'
)
->
dict
:
def
search
(
self
,
order
:
str
=
'breadth'
,
root_id
:
str
=
None
,
linktype
:
str
=
'links'
,
stop_at
:
str
=
None
)
->
dict
:
path
:
list
=
list
()
visited
:
set
=
set
()
if
root_id
is
None
:
...
...
@@ -192,6 +195,12 @@ class NodeGraph ( Node ) :
ncurrent
:
Node
=
self
.
get_node
(
v
)
visited
=
visited
|
set
([
v
])
path
.
append
(
ncurrent
.
identification
()
)
#
# ADDED STOP CRITERION FOR WHEN THE STOP NODE IS FOUND
if
not
stop_at
is
None
:
if
stop_at
==
v
:
S
=
[]
break
links
=
ncurrent
.
get_links
(
linktype
)
for
w
in
links
:
if
not
w
in
visited
and
len
(
w
)
>
0
:
...
...
@@ -208,12 +217,29 @@ class NodeGraph ( Node ) :
if
not
w
in
visited
and
len
(
w
)
>
0
:
S
=
[
*
[
w
],
*
S
]
# STACK
path
.
append
(
ncurrent
.
identification
()
)
#
# ADDED STOP CRITERION FOR WHEN THE STOP NODE IS FOUND
if
not
stop_at
is
None
:
if
stop_at
==
v
:
S
=
[]
break
return
(
{
'path'
:
path
,
'order'
:
order
,
'linktype'
:
linktype
}
)
def
calculate_node_level
(
self
,
node
:
Node
)
->
None
:
level
=
len
(
self
.
search
(
root_id
=
node
.
identification
(),
linktype
=
'ascendants'
)[
'path'
]
)
-
1
def
calculate_node_level
(
self
,
node
:
Node
,
stop_at
:
str
=
None
,
order
:
str
=
'depth'
)
->
None
:
note__
=
"""
SEARCHING FOR ASCENDANTS WILL YIELD A
DIRECT PATH IF A DEPTH SEARCH IS EMPLOYED.
IF THERE ARE SPLITS ONE MUST BREAK THE SEARCH.
SPLITS SHOULD NOT BE PRESENT IN ASCENDING DAG
SEARCHES. SPLIT KILLING IS USED IF depth AND
stop_at ARE SPECIFIED
"""
level
=
len
(
self
.
search
(
root_id
=
node
.
identification
(),
linktype
=
'ascendants'
)[
'path'
],
order
=
order
,
stop_at
=
stop_at
)
-
1
node
.
set_level
(
level
)
def
hprint
(
self
,
node
:
Node
,
visited
:
set
,
...
...
@@ -221,7 +247,7 @@ class NodeGraph ( Node ) :
bCalcLevel
=
True
)
->
(
str
,
int
)
:
I
=
I
+
1
if
bCalcLevel
:
self
.
calculate_node_level
(
node
)
self
.
calculate_node_level
(
node
,
stop_at
=
self
.
get_root_id
()
)
head_string
=
"{
\"
source
\"
:
\"
"
+
node
.
identification
()
+
"
\"
,
\"
id
\"
: "
+
str
(
I
)
head_string
=
head_string
+
",
\"
level
\"
: "
+
str
(
node
.
level
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录