Skip to content
Tahsin Mayeesha edited this page Jun 9, 2018 · 4 revisions

Fa2l :

  • Directed/Undirected : Fa2l does not work with directed graphs. So the graphs are being converted to directed via networkx for now.

  • Prevent_overlapping : When Prevent_overlapping parameter is set to True the output positions are between 0 to 1, while when prevent_overlapping parameter is False the output positions can be negative and between (-4000,4000) in general. This happens because of using different equations while calculating repulsion force. See here for details.

Visualization :

  • Viz Functions : Networkx provides functions for drawing nodes,edges and labels with varying node size, node color and opacity for both nodes and edges. Using them the visualization can be improved to a high extent.

  • Label Overlap : The label overlap is being handled with the AdjustText package. Adjust Text takes in a set of matplotlib Text objects and iteratively adjusts them to minimize label overlaps.

  • Label resizing : Label resizing based on node size has not been implemented yet. Instead of drawing all the labels that it's possible to draw the labels for a set of specific nodes has been verified.

Layout :

  • Layout is the key issue that's being addressed now. Fa2l can not prevent node overlapping completely. The suggested method for setting the scale goes like this :
1- set the node size to what we like;
2- set the scale to 10;
3- run fa2l;
4- if any of the 20 top nodes are overlapping (within ( node_a_size + node_b_size ) / 2 of each other), increase the scale;
5- if any of the 20 top nodes are more than 10 pixels apart, decrease the scale;
6- repeat 4 - 6 until neither 4 or 5 are true.

For steps 4 and 5, use a binary search to narrow down on the correct scale.  

Implementing Function for Checking Node Overlaps :

For setting the scale in fa2l automatically it's important to find out which of the top nodes are overlapping.To check which of the nodes are overlapping we check if the distance between the center of two nodes is less than the summation of their radius.

But for the visualization networkx's built-in draw_networkx_nodes function uses matplotlib's scatter function which takes in the node sizes in markersize**2 in pts(which is different from the data units in X and Y axis, so it's not possible to use the sizes as radius. See here for more details.

To handle that currently a custom function draw_networkx_nodes_custom for drawing network nodes with matplotlib patches(patches are geometric objects that's attached to the figure) is implemented which basically draws the circles in data units by setting the radius = node size.

Extracting Correct Scale :

When the algo for extracting correct scale with binary search over a range is implemented, the function is able to find a good repulsion force(scale) for which there's no overlap between the top k nodes(k=number of largest nodes to consider by size) but the nodes are often too far apart from each other. Finding a correct scale may take a lot of iterations. With my machine it's also not possible to just run fa2l for 2000+ iterations without crashing.