-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added optional keyword parameter to gplot for plotting Chain Graphs #110
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #110 +/- ##
==========================================
+ Coverage 32.02% 37.38% +5.35%
==========================================
Files 9 9
Lines 509 527 +18
==========================================
+ Hits 163 197 +34
+ Misses 346 330 -16
Continue to review full report at Codecov.
|
Hi, Sorry for the huge delay here. I like this feature, but I am not sure if |
@@ -35,9 +60,17 @@ function graphline(g::AbstractGraph{T}, locs_x, locs_y, nodesize::Real, arrowlen | |||
endx = locs_x[j] + nodesize*cos(θ+π) | |||
endy = locs_y[j] + nodesize*sin(θ+π) | |||
lines[e_idx] = [(startx, starty), (endx, endy)] | |||
arr1, arr2 = arrowcoords(θ, endx, endy, arrowlength, angleoffset) | |||
arrows[e_idx] = [arr1, (endx, endy), arr2] | |||
if chainGraph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to have used tabs here. For consistency with the rest of the project we should spaces instead.
end | ||
|
||
function filterUndef(array) | ||
result = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result = [] | |
result = eltype(array)[] |
return has_edge(g,dst(e),src(e)) | ||
end | ||
|
||
function filterUndef(array) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function filterUndef(array) | |
function filterAssigned(array) |
or filterDefined
.
Reason is, that when one uses the filter
function then predicate specifies what should stay in the array and not what should be filtered out.
if result == [] | ||
result = typeof(array[i])[] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if result == [] | |
result = typeof(array[i])[] | |
end |
We can remove this as we can already initialize the list correctly above.
if chainGraph | ||
if !hasReverseEdge(g,e) | ||
arr1, arr2 = arrowcoords(θ, endx, endy, arrowlength, angleoffset) | ||
arrows[e_idx] = [arr1, (endx, endy), arr2] | ||
end | ||
else | ||
arr1, arr2 = arrowcoords(θ, endx, endy, arrowlength, angleoffset) | ||
arrows[e_idx] = [arr1, (endx, endy), arr2] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if chainGraph | |
if !hasReverseEdge(g,e) | |
arr1, arr2 = arrowcoords(θ, endx, endy, arrowlength, angleoffset) | |
arrows[e_idx] = [arr1, (endx, endy), arr2] | |
end | |
else | |
arr1, arr2 = arrowcoords(θ, endx, endy, arrowlength, angleoffset) | |
arrows[e_idx] = [arr1, (endx, endy), arr2] | |
end | |
if !(chainGraph && !hasReverseEdge(g, e)) | |
arr1, arr2 = arrowcoords(θ, endx, endy, arrowlength, angleoffset) | |
arrows[e_idx] = [arr1, (endx, endy), arr2] | |
end |
@@ -1,7 +1,24 @@ | |||
function hasReverseEdge(g, e) | |||
return has_edge(g,dst(e),src(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return has_edge(g,dst(e),src(e)) | |
return has_edge(g, dst(e), src(e)) |
Hi all,
I added support for "mixed model" graphs or so called "chain graphs" with an optional keyword parameter called "chainGraph". It (selectively) removes the double arrows for bi-directional edges for SimpleDiGraphs.
Visual Examples below:
gives
gives
I also added a (visual) test set for that case. I haven't implemented it for the
linestyle="curve"
option though. Should an error be thrown in that case (until it's implemented)?I'm also wondering about the placement of the helper functions
hasReverseEdge
andfilterUndef
currently they reside in lines.jl where they are used.kr,
Dieter