networkx / outreachy

BSD 3-Clause "New" or "Revised" License
7 stars 75 forks source link

added heatmap #206

Closed Schefflera-Arboricola closed 1 year ago

Schefflera-Arboricola commented 1 year ago

heatmap task

MridulS commented 1 year ago

Hmm, interesting. It seems like there is no speedups on your machine while running the timing task. Maybe something you can investigate? @Schefflera-Arboricola

Schefflera-Arboricola commented 1 year ago

@MridulS sir,

  1. In the CPU core utilization window, the work was not distributed uniformly among all the 8 cores, most of the work was on one core at a time while the script was running.

  2. The CPU% was around 100, and the number of threads for the process was 17(rarely become 18 or 20). It was the same when I executed currFun for the standard and the parallel graph separately.

  3. I even tried it for 1000 nodes graphs but I was still getting most of the values in the heatmap around 1.

  4. I recently pulled some new changes and I was getting this error:

    betweenness = dict.fromkeys(G, 0.0)  # b[v]=0 for v in G
                  ^^^^^^^^^^^^^^^^^^^^^
    TypeError: 'ParallelGraph' object is not iterable

    So I added this code to interface.py:

    
    class ParallelGraph:
    __networkx_plugin__ = "parallel"
    
    def __init__(self, graph_object):
        self.graph_object = graph_object
    
    def is_multigraph(self):
        return self.graph_object.is_multigraph()
    
    def is_directed(self):
        return self.graph_object.is_directed()

but I am still getting a similar heatmap.

Running on: MacBook Air(macOS: 13.3.1(a))

Could you please help me figure out what might be the issue here, or redirect me to some resource where I could learn more about it(parallel algorithms and their benchmarking, etc.)?

Also, if a cell in the heatmap corresponds to a graph with a particular number of nodes and a particular edge probability, then why have we used `0.5` instead of `p` [here](https://github.com/networkx/nx-parallel/blob/main/timing/timing_individual_function.py#L21)?

Thank you very much for your patience :)
Schefflera-Arboricola commented 1 year ago

@MridulS sir, I think it was happening because I didn't run pip install -e ".[developer]" after setting up the environment, and I also didn't get that TypeError now. The additional code in interface.py was not required. I have updated the heat map.

But I am still doubtful about this :

Also, if a cell in the heatmap corresponds to a graph with a particular number of nodes and a particular edge probability, then why have we used 0.5 instead of p here?

I got this map for p

Screenshot 2023-10-08 at 7 55 00 PM

and this for 0.5

Screenshot 2023-10-08 at 7 56 20 PM

Thank you :)

MridulS commented 1 year ago

Also, if a cell in the heatmap corresponds to a graph with a particular number of nodes and a particular edge probability, then why have we used 0.5 instead of p here?

Yes that looks like a bug, it should be using p to create the random graph. Good catch!

Could you send a PR to the nx-parallel repo to fix it?

Schefflera-Arboricola commented 1 year ago

@MridulS done. see here

MridulS commented 1 year ago

thanks!