Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
OpenIDE-Module: cz.cvut.fit.gephi.multimode
OpenIDE-Module-Localizing-Bundle: cz/cvut/fit/gephi/multimode/Bundle.properties
OpenIDE-Module-Requires: org.openide.windows.WindowManager
OpenIDE-Module-Specification-Version: 0.1.2
OpenIDE-Module-Specification-Version: 0.1.3

6 changes: 5 additions & 1 deletion src/cz/cvut/fit/gephi/multimode/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ OpenIDE-Module-Long-Description=\
This plugin allows multimode networks projection. \
You can project your bipartite (2-mode) graph to monopartite (one-mode) graph. \
The projection/transformation is based on the matrix multiplication approach and allows different types of transformations. \
The limitation is matrix multiplication - large matrix multiplication takes time and memory.
The limitation is matrix multiplication - large matrix multiplication takes time and memory.\n\
Threshold to limit the number of generated edges and option to convert directed graphs to undirected has been added\nThe weights are taken into account
OpenIDE-Module-Name=MultimodeNetworksTransformationPlugin
OpenIDE-Module-Short-Description=Multimode Networks Transformations
MultiModeWindowTopComponent.attributes.toolTipText=Attribute column which represents node type.
Expand All @@ -20,3 +21,6 @@ MultiModeWindowTopComponent.removeNodes.toolTipText=Remove affected Nodes
MultiModeWindowTopComponent.load.text=Load attributes
MultiModeWindowTopComponent.graphColoring.text=Graph Coloring
MultiModeWindowTopComponent.bipartiteLabel.text=Bipartite: ?
MultiModeWindowTopComponent.jLabel1.text=Threshold
MultiModeWindowTopComponent.threshold.text=0.0
MultiModeWindowTopComponent.directed.text=directed
59 changes: 44 additions & 15 deletions src/cz/cvut/fit/gephi/multimode/LongTaskTransformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ public class LongTaskTransformation implements LongTask, Runnable {
private String outDimension;
private boolean removeEdges = true;
private boolean removeNodes = true;
private boolean directed=false;
private boolean considerDirected=false;
private double threshold=0.0;

public LongTaskTransformation(AttributeColumn attributeColumn, String inDimension, String commonDimension, String outDimension, boolean removeEdges, boolean removeNodes) {
public LongTaskTransformation(AttributeColumn attributeColumn, String inDimension, String commonDimension, String outDimension,double threshold, boolean removeEdges, boolean removeNodes, boolean considerDirected) {
this.attributeColumn = attributeColumn;
this.inDimension = inDimension;
this.commonDimension = commonDimension;
this.outDimension = outDimension;
this.removeEdges = removeEdges;
this.removeNodes = removeNodes;
this.considerDirected=considerDirected;
this.threshold=threshold;
}

@Override
Expand All @@ -43,8 +48,14 @@ public void run() {
// graph
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getModel();
Graph graph = graphModel.getGraphVisible();
//Graph graph = graphModel.getUndirectedGraphVisible();
Graph graph;
if (considerDirected){
graph = graphModel.getGraphVisible();
directed=graphModel.isDirected();
} else {
graph = graphModel.getUndirectedGraphVisible();
directed=false;
}
Node[] nodes = graph.getNodes().toArray();

// matrix axis
Expand Down Expand Up @@ -72,11 +83,12 @@ public void run() {
secondHorizontal.add(n);
}
}

Progress.start(progressTicket, firstVertical.size()+5);

if (cancelled) {
return;
}
Progress.progress(progressTicket);
Progress.progress(progressTicket,1);

// first matrix
Matrix firstMatrix = new Matrix(firstVertical.size(), firstHorizontal.size());
Expand All @@ -86,9 +98,15 @@ public void run() {
try {
intersection.retainAll(firstHorizontal);
for (Node neighbour : intersection) {
firstMatrix.set(i, firstHorizontal.indexOf(neighbour), 1);
int j=firstHorizontal.indexOf(neighbour);
if (j > -1){
Edge edge = graph.getEdge(firstVertical.get(i), firstHorizontal.get(j));
if (edge!= null) {
float w=edge.getWeight();
firstMatrix.set(i, j, w);
}
}
} catch (UnsupportedOperationException ex) {
}} catch (UnsupportedOperationException ex) {
System.out.println("exception");
// TODO - exception handler
}
Expand All @@ -102,9 +120,16 @@ public void run() {
if (intersection != null && intersection.size() > 0) {
try {
intersection.retainAll(secondHorizontal);
for (Node neighbour : intersection) {
secondMatrix.set(i, secondHorizontal.indexOf(neighbour), 1);
}
for (Node neighbour : intersection) {
int j=secondHorizontal.indexOf(neighbour);
if (j>-1){
Edge edge =graph.getEdge(secondVertical.get(i), secondHorizontal.get(j));
if (edge!= null) {
float w=edge.getWeight();
secondMatrix.set(i, j, w);
}
}
}
} catch (UnsupportedOperationException ex) {
System.out.println("exception");
// TODO - exception handler
Expand All @@ -114,13 +139,13 @@ public void run() {
if (cancelled) {
return;
}
Progress.progress(progressTicket, "Multiplication");
Progress.progress(progressTicket, "Multiplication",2);

Matrix result = firstMatrix.timesParallelIndexed(secondMatrix);
if (cancelled) {
return;
}
Progress.progress(progressTicket, "Removing nodes/edges");
Progress.progress(progressTicket, "Removing nodes/edges",3);


if (removeNodes) {
Expand Down Expand Up @@ -150,7 +175,7 @@ public void run() {
if (cancelled) {
return;
}
Progress.progress(progressTicket, "Creating new edges");
Progress.progress(progressTicket, "Creating new edges",4);
AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
AttributeModel model = ac.getModel();
AttributeColumn edgeTypeCol = model.getEdgeTable().getColumn("MMNT-EdgeType");
Expand All @@ -162,15 +187,19 @@ public void run() {
Edge ee = null;
for (int i = 0; i < result.getM(); i++) {
for (int j = 0; j < result.getN(); j++) {
if (graph.contains(firstVertical.get(i)) && graph.contains(secondHorizontal.get(j)) && graph.getEdge(firstVertical.get(i), secondHorizontal.get(j)) == null && result.get(i, j) > 0) {
ee = graphModel.factory().newEdge(firstVertical.get(i), secondHorizontal.get(j), (float) result.get(i, j), graphModel.isDirected());
if (graph.contains(firstVertical.get(i)) && graph.contains(secondHorizontal.get(j)) && graph.getEdge(firstVertical.get(i), secondHorizontal.get(j)) == null && result.get(i, j) > threshold) {
ee = graphModel.factory().newEdge(firstVertical.get(i), secondHorizontal.get(j), (float) result.get(i, j),this.directed );
if (!ee.isSelfLoop()) {
ee.getEdgeData().getAttributes().setValue(edgeTypeCol.getIndex(), inDimension + "<--->" + outDimension);
//ee.getEdgeData().setLabel(inDimension + "-" + outDimension);
graph.addEdge(ee);
}
}
}
if (cancelled) {
return;
}
Progress.progress (progressTicket,i+5);
}
Progress.finish(progressTicket);
}
Expand Down
88 changes: 66 additions & 22 deletions src/cz/cvut/fit/gephi/multimode/MultiModeWindowTopComponent.form
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,45 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="removeNodes" min="-2" max="-2" attributes="0"/>
<Component id="removeEdges" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="attributeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="leftlabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="rightLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="secondMatrix" max="32767" attributes="0"/>
<Component id="firstMatrix" max="32767" attributes="0"/>
<Component id="attributes" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="jSeparator1" alignment="1" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="start" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="172" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="removeEdges" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="removeNodes" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="66" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="attributeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="leftlabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="rightLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="secondMatrix" pref="191" max="32767" attributes="0"/>
<Component id="firstMatrix" max="32767" attributes="0"/>
<Component id="attributes" max="32767" attributes="0"/>
</Group>
<Component id="jLabel1" min="-2" pref="83" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="start" min="-2" max="-2" attributes="0"/>
<Component id="directed" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
</Group>
<Component id="jSeparator1" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="threshold" min="-2" pref="71" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
Expand Down Expand Up @@ -86,9 +94,20 @@
<Component id="rightLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="removeEdges" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="removeNodes" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="removeEdges" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="directed" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="removeNodes" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="threshold" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="start" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
Expand All @@ -98,7 +117,7 @@
<Component id="graphColoring" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="bipartiteLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="60" max="32767" attributes="0"/>
<EmptySpace pref="87" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -215,5 +234,30 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="directed">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/cvut/fit/gephi/multimode/Bundle.properties" key="MultiModeWindowTopComponent.directed.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/cvut/fit/gephi/multimode/Bundle.properties" key="MultiModeWindowTopComponent.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="threshold">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="cz/cvut/fit/gephi/multimode/Bundle.properties" key="MultiModeWindowTopComponent.threshold.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="thresholdActionPerformed"/>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="thresholdFocusLost"/>
</Events>
</Component>
</SubComponents>
</Form>
Loading