Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
648bc91c
Commit
648bc91c
authored
5 years ago
by
Jacob Wahlman
Browse files
Options
Downloads
Patches
Plain Diff
changed docstring and changed to set in BFS
parent
740e51da
No related branches found
No related tags found
1 merge request
!7
Resolve "Operation Traversing"
Pipeline
#10184
passed
5 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/abstract_operation.py
+3
-9
3 additions, 9 deletions
b_asic/abstract_operation.py
b_asic/utilities.py
+4
-4
4 additions, 4 deletions
b_asic/utilities.py
with
7 additions
and
13 deletions
b_asic/abstract_operation.py
+
3
−
9
View file @
648bc91c
...
...
@@ -4,7 +4,7 @@ TODO: More info.
"""
from
abc
import
abstractmethod
from
typing
import
List
,
Dict
,
Optional
,
Any
from
typing
import
List
,
Set
,
Dict
,
Optional
,
Any
from
numbers
import
Number
from
b_asic.port
import
InputPort
,
OutputPort
...
...
@@ -107,14 +107,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
return
neighbours
def
traverse
(
self
)
->
List
[
Operation
]:
"""
Traverse the the operation tree and return operation where type matches.
If the type is None then return the entire tree.
Keyword arguments:
type_ -- the operation type to search for (default None)
"""
def
traverse
(
self
)
->
Set
[
Operation
]:
"""
Traverse the operation tree and return a generator with start point in the operation.
"""
return
breadth_first_search
(
self
)
# TODO: More stuff.
This diff is collapsed.
Click to expand it.
b_asic/utilities.py
+
4
−
4
View file @
648bc91c
...
...
@@ -3,19 +3,19 @@ B-ASIC Operation Module.
TODO: More info.
"""
from
typing
import
Lis
t
from
typing
import
Se
t
from
collections
import
deque
from
b_asic.operation
import
Operation
def
breadth_first_search
(
start
:
Operation
)
->
List
[
Operation
]
:
def
breadth_first_search
(
start
:
Operation
)
->
Operation
:
"""
Use breadth first search to traverse the operation tree.
"""
visited
:
Lis
t
[
Operation
]
=
[
start
]
visited
:
Se
t
[
Operation
]
=
{
start
}
queue
=
deque
([
start
])
while
queue
:
operation
=
queue
.
popleft
()
yield
operation
for
n_operation
in
operation
.
neighbours
:
if
n_operation
not
in
visited
:
visited
.
a
ppen
d
(
n_operation
)
visited
.
a
d
d
(
n_operation
)
queue
.
append
(
n_operation
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment