OmarShafie / hadith

a search engine which provides Visual analysis of Hadith Isnad tree
https://dev.omarshafie.com/hadith/
GNU General Public License v3.0
29 stars 2 forks source link

adjust weights of links #10

Open OmarShafie opened 4 years ago

OmarShafie commented 4 years ago

As number of hadiths increases within a search, the link widths (weight) grows linearly, this makes presenting a comparison really difficult as heavy links significantly outlarge lighter ones..

I suggest that as the knowing the exact accumulation of number of hadith in one link is not of sifnificant value to make visual wight in the link grows very slowly..

It is worth trying: (logarithmic scale) Harmonic scale?

OmarShafie commented 4 years ago

Update: I have tried to use different scales however was not impressed by the generated vizualisations

Logarithmic is not very suitable as it shrinks too much of it

The square root scale is better as it is closer to linear

a better mix is a Sqrt(n * lon(n))

but even that was not very interesting change

OmarShafie commented 4 years ago

I found a way, which should work, that is by changing initial layer only

OmarShafie commented 3 years ago

The implementation has been made,

However there is a slight issue as the fraction of the distributed flow is stll linear.

OmarShafie commented 3 years ago

I have another approach, The requirement is that we want to preserve the perception of the weights of the links, but make the changes seems less drastic. For that, we can use a known principle in visualization, which is scaling. Naive scaling of all edges will not preserve some key aspects of sankey, such as if IN == OUT, then it should stay so even after scaling.

Formally, for any 2 edges with weights w1 and w2: if w1 < w2, then w1' < w2'. if w1 = w2, then w1' = w2'. for any node, if sum(IN) = sum(OUT), then sum(IN') = sum(OUT') which equivalent to a probability preserve.

Here is a suggested algorithm, We initially scale all edges, then in a greedy approach we adjust to meet the 3rd rule. sort nodes by importance, for node in nodes: which link is not locked, if IN = OUT, then pass else, change one (meet min/max or LEFT or RIGHT? not sure yet) lock both

OmarShafie commented 3 years ago

A better approach is to start from the most important set of nodes that for a strongly connected components. https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm

then scale these and propagate the changes linearly in each direction.

one caveat of this approach, is that links that are on the side