-
Notifications
You must be signed in to change notification settings - Fork 0
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 type functions, general heuristics and metagraph #3
base: main
Are you sure you want to change the base?
Conversation
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.
Please check the comments, there is a bug in the heuristic functions I think.
…degree and betweenness. Fixed some other bugs. Changed complete_graph to CompleteGraph because it used to be called this in LightGraphs version in the dependencies (1.2). It didn't otherwise work in the package environment.
src/SyntheticNetworks.jl
Outdated
dist_spatial = map(j -> euclidean(graph.vertexpos[i], graph.vertexpos[j]), 1:nv(graph)) | ||
l_edge = Step_G34(graph, i, dist_spatial, r, methods[types]) | ||
if l_edge == 0 | ||
n_actual -= 1 |
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.
what is happening here? are you sure resetting the loop index does not cause problems?
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.
My idea was to redraw a node, if there isn't any node that the new node can be connected to. But I see now that there is definitely a problem, because I don't remove the added vertex, edge and type.
n_actual -= 1 | |
pop!(types) | |
rem_vertex!(graph,nv(graph)) | |
rem_edge!(graph, nv(graph),min_dist_vertex) | |
n_actual -= 1 | |
But this should be okay, I think.
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.
I tried out the suggestion above, but I get graphs smaller than I wanted. I'm not sure what would make more sense to do if no node is found.
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 connect a new node always in step G2, so it only means that there is no additional link added.
Sometimes there might just be no possibility. The resulting graph should havve the same number of nodes but less edges.
We could, however, also redraw the node location and try again (limited to k
trials, which is another parameter then). This can be done in the following way: You first draw random numbers and determine which steps have to be performed. then you execute the respective steps, returning the new edges if possible or redraw the location up to k
times (you can use try/catch
for that maybe.) Only then, edges are added.
src/Heuristics.jl
Outdated
maximum_degree, maximum_betweenness | ||
function maximum_value_heuristics(f::Function, max_val) | ||
# h(g,i) = f(g)[i] < max_val | ||
h = (g,i) -> f(g)[i] < max_val ? 1 : 0 |
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.
why don't you return f(g)[i] < max_val
as boolean directly?
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.
I was aiming to do that. When I didn't have the ? 1 : 0 at the end, it didn't work later on when I was trying to use the output in findall(). I tried to specify the output as boolean, but couldn't figure out how.
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.
I think it works now.
Codecov Report
@@ Coverage Diff @@
## master #3 +/- ##
===========================================
- Coverage 62.16% 51.85% -10.32%
===========================================
Files 1 2 +1
Lines 74 108 +34
===========================================
+ Hits 46 56 +10
- Misses 28 52 +24
Continue to review full report at Codecov.
|
…d. Changed the rest to work with NodeType structs.
…bility heuristics.
…ecking the node types in step G2.
…from G34, 2) fixed how a node is chosen from candidates. Changes in heuristics, which are now in conditionals instead of defining functions in NodeTypes. Final (?) version for BA-Ece :)
No description provided.