Skip to content
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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

eckuru
Copy link
Collaborator

@eckuru eckuru commented Sep 2, 2020

No description provided.

Copy link
Member

@luap-pik luap-pik left a 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.

src/Heuristics.jl Outdated Show resolved Hide resolved
src/Heuristics.jl Outdated Show resolved Hide resolved
luap-pik and others added 3 commits September 3, 2020 13:04
…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.
@eckuru eckuru requested a review from luap-pik September 3, 2020 17:03
src/SyntheticNetworks.jl Outdated Show resolved Hide resolved
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
Copy link
Member

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?

Copy link
Collaborator Author

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.

Suggested change
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.

Copy link
Collaborator Author

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.

Copy link
Member

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.

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
Copy link
Member

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_valas boolean directly?

Copy link
Collaborator Author

@eckuru eckuru Sep 3, 2020

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.

Copy link
Member

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-commenter
Copy link

codecov-commenter commented Sep 6, 2020

Codecov Report

Merging #3 into master will decrease coverage by 10.31%.
The diff coverage is 50.00%.

Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
src/Heuristics.jl 0.00% <0.00%> (ø)
src/SyntheticNetworks.jl 59.57% <60.29%> (-2.59%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a0b9bf...049f154. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants