-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from nulab/dev-23/self-loops
- Loading branch information
Showing
14 changed files
with
176 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Run Unit Tests | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
unit-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache: false | ||
- name: Run Tests | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package monitor | ||
|
||
// constant keys to help standardize log output | ||
const ( | ||
KeySkip = "skip" | ||
KeySelfLoop = "self-loop" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package postprocessor | ||
|
||
import "github.com/nulab/autog/internal/graph" | ||
|
||
// UnreverseEdges restores edge direction that was reversed during the cycle-breaking phase | ||
func UnreverseEdges(g *graph.DGraph) { | ||
for _, e := range g.Edges { | ||
if e.IsReversed { | ||
// reverse back | ||
e.Reverse() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package preprocessor | ||
|
||
import ( | ||
"github.com/nulab/autog/internal/graph" | ||
imonitor "github.com/nulab/autog/internal/monitor" | ||
"github.com/nulab/autog/internal/processor" | ||
) | ||
|
||
func IgnoreSelfLoops(g *graph.DGraph) processor.F { | ||
del := graph.EdgeSet{} | ||
for _, e := range g.Edges { | ||
if e.From == e.To { | ||
imonitor.Log(imonitor.KeySelfLoop, "removed: "+e.From.ID) | ||
del[e] = true | ||
} | ||
} | ||
for e := range del { | ||
// using the appropriate From-Out and To-In fields for clarity, | ||
// but it's always the same node with the same incoming and outgoing edge | ||
e.From.Out.Remove(e) | ||
e.To.In.Remove(e) | ||
g.Edges.Remove(e) | ||
} | ||
return func(g *graph.DGraph) { | ||
for e := range del { | ||
imonitor.Log(imonitor.KeySelfLoop, "added: "+e.From.ID) | ||
e.From.Out.Add(e) | ||
e.To.In.Add(e) | ||
g.Edges.Add(e) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters