Friday 6 July 2012

Week 4,5,6 - Interaction Comparison

Sorry for the delay on the blog report. I had exams and a trip to make. So, I was away for 9 days.
And also, Interaction comparison was a bit complex as it first involved finding out all the possible interactions in a pathway and then comparing the interactions in two pathways. Right now, Interaction Comparison is not perfect as it does not take into account the line's connections (i.e which lines connect to which others). i.e As long as DataNodes are the same (i.e Xref same) in the interactions being compared , then the interactions are considered to be matching.

When I say Interaction, I mean : A group of DataNodes, Lines (these have start and end points i.e <point> tags with graphRefs) & anchors on the lines interacting in such a way that they are all connected , like in a network, where each of the interacting partners are connected to all the others either directly or indirectly. Here, the interaction must comprise of at least 2 datanodes.

Example of Interactions

Example 2: There is only one interaction in the example above

Algorithm for finding out the interactions (group of connected datanodes) in a Pathway :
In this algorithm , we loop through the lines in a pathway instead of DataNodes.
This algorithm requires "DataNode-Comparison" results before hand because we will be using only those lines which connect to at least one of the Datanodes from the Datanode-Comparison result (or) those which don't connect to any datanodes. All the other lines wont matter because for any two interactions to match, all the Datanodes present in the interactions must match.


1. Get a list of those lines in a pathway which connect to at least one DataNode from the Datanode comparison result. This list also includes the lines which do not connect to any Datanodes and instead have end-points referring to the anchors positioned on other lines. 


2. We loop through each line in this list (outer 'for' loop, let us call this line : Root Line) and see if other lines present in the list (inner 'for' loop) interact with the root line i.e. see if other lines in the list have something in common with the root line. This something common could be a DataNode or an anchor: where this line connects to an anchor on the other line (or) the other line refers to an anchor present on this line ).


3. This "something common" represents the "interaction partners" present on a line. Whenever the root line and the line from the inner-for-loop have a match in at least one of their interaction partners, they are considered to be connected (forming part of an interaction) and their interaction partners are clubbed. The lines and its datanodes are then part of the interaction.


4. Similarly, the other lines are checked to see if they have an interaction partner which could be present in this clubbed "interaction partners list". If so, the lines are considered to be connected to the root line  (directly or indirectly), and the line and its connecting DataNodes (if any) become part of the interaction.


5. At the end of each loop of  the outer-for-loop, we get a list of the lines and their connecting DataNodes which are either directly or indirectly connected to the root line. In other words, we get an interaction (a list of Datanodes and Lines). Note : Not all the root lines would go on to form an interaction.

6. At the end of the outer-for-loop we get the list of all the Interactions in a pathway. Thus using this approach we find the list of interactions in the 2 pathways. For now, these interactions in the 2 pathways are compared using only the Datanodes present in the interactions, as I am yet to figure out a way where lines' flow/direction is also included in the comparison.

Assumptions in the algorithm:
1. The Graphref attributes in the <point> tag inside a <line> tag, when not referring to DataNodes , are assumed to be referring to Anchors. 
2. Only the first and the last graphRefs of a line are used (i.e the start and end-points of a line) to look for referring Datanodes or Anchors.



Screenshot: Comparing Interactions in a pathway. Pathways in the 2 windows are the same. 



No comments:

Post a Comment