Author: ghuck
Date: 2011-06-09 10:42:56 -0700 (Thu, 09 Jun 2011)
New Revision: 25693
Added:
csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/
csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/Makefile
csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.cpp
csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.h
Modified:
csplugins/trunk/soc/ghuck/IgraphPlugin/build.xml
csplugins/trunk/soc/ghuck/IgraphPlugin/src/cytoscape/plugins/igraph/IgraphInterface.java
csplugins/trunk/soc/ghuck/IgraphPlugin/src/cytoscape/plugins/igraph/NodeCount.java
Log:
Modified: csplugins/trunk/soc/ghuck/IgraphPlugin/build.xml
===================================================================
--- csplugins/trunk/soc/ghuck/IgraphPlugin/build.xml 2011-06-09 17:12:42 UTC
(rev 25692)
+++ csplugins/trunk/soc/ghuck/IgraphPlugin/build.xml 2011-06-09 17:42:56 UTC
(rev 25693)
@@ -29,6 +29,7 @@
<!-- Define igraph directory -->
<property name="igraph.dir" value="/Users/gerardohuck/igraph"/>
+ <property name="igraphWrapper_src.dir" value="${src.dir}/igraphWrapper"/>
<!-- Inheritable properties -->
<property name="debug" value="on"/>
@@ -41,7 +42,7 @@
<available file="${cytoscape.dir}/cytoscape.jar"
property="cytoscape.present"/>
<available file="${root.dir}/plugin.props" property="plugin.prop.present"/>
<available file="${root.dir}/License.txt" property="license.present"/>
- <available file="${igraph.dir}/src/.libs/libigraph.dylib"
property="igraph.lib.present"/>
+ <available file="${root.dir}/libigraphWrapper.dylib"
property="igraphWrapper.lib.present"/>
<!-- Define the java class path -->
<path id="project.class.path">
@@ -76,9 +77,18 @@
</target>
<!-- =================================================================== -->
+ <!-- Executes "make" in igraphWrapper, buiding static library -->
+ <!-- =================================================================== -->
+ <target name="igraphWrapper_compile" depends="init" >
+ <echo message="Compiling igraph wrapper library..."/>
+ <exec executable="make" dir="${igraphWrapper_src.dir}"/>
+ </target>
+
+
+ <!-- =================================================================== -->
<!-- Creates the plugin jar file
-->
<!-- =================================================================== -->
- <target name="jar" depends="compile, copy_plugin_prop, copy_license,
copy_igraph_lib">
+ <target name="jar" depends="compile, copy_plugin_prop, copy_license,
copy_igraphWrapper_lib">
<jar destfile="${project.jar}">
<manifest> <attribute name="Cytoscape-Plugin" value="${plugin_class}"/>
</manifest>
<fileset dir="${build.dir}" includes="**"/>
@@ -100,11 +110,11 @@
</target>
<!-- =================================================================== -->
- <!-- If igraph.lib exist, copy it to build directory -->
+ <!-- If igraphWrapper.lib exist, copy it to build directory -->
<!-- =================================================================== -->
- <target name="copy_igraph_lib" if="igraph.lib.present">
- <echo message="copying igraph lib to build dir"/>
- <copy todir="${build.dir}/"
file="${igraph.dir}/src/.libs/libigraph.dylib"/>
+ <target name="copy_igraphWrapper_lib" depends="igraphWrapper_compile">
+ <echo message="copying igraphWrapper lib to build dir"/>
+ <copy todir="${build.dir}/"
file="${igraphWrapper_src.dir}/libigraphWrapper.dylib"/>
</target>
<!-- =================================================================== -->
@@ -126,7 +136,9 @@
<target name="clean" depends="init">
<delete dir="${build.dir}"/>
<delete file="${root.dir}/${project.jar}"/>
- <delete file="${root.dir}/${test.jar}"/>
+ <exec executable="make" dir="${igraphWrapper_src.dir}">
+ <arg line="clean"/>
+ </exec>
</target>
Modified:
csplugins/trunk/soc/ghuck/IgraphPlugin/src/cytoscape/plugins/igraph/IgraphInterface.java
===================================================================
---
csplugins/trunk/soc/ghuck/IgraphPlugin/src/cytoscape/plugins/igraph/IgraphInterface.java
2011-06-09 17:12:42 UTC (rev 25692)
+++
csplugins/trunk/soc/ghuck/IgraphPlugin/src/cytoscape/plugins/igraph/IgraphInterface.java
2011-06-09 17:42:56 UTC (rev 25693)
@@ -24,8 +24,19 @@
DoubleByReference stor_end;
DoubleByReference end;
}
-
+ public class Igraph_t extends Structure {
+ int n;
+ int directed;
+ Igraph_vector_t from;
+ Igraph_vector_t to;
+ Igraph_vector_t oi;
+ Igraph_vector_t ii;
+ Igraph_vector_t os;
+ Igraph_vector_t is;
+ // void *attr;
+ }
+
/* -------------------------------------------------- */
/* Data types */
Modified:
csplugins/trunk/soc/ghuck/IgraphPlugin/src/cytoscape/plugins/igraph/NodeCount.java
===================================================================
---
csplugins/trunk/soc/ghuck/IgraphPlugin/src/cytoscape/plugins/igraph/NodeCount.java
2011-06-09 17:12:42 UTC (rev 25692)
+++
csplugins/trunk/soc/ghuck/IgraphPlugin/src/cytoscape/plugins/igraph/NodeCount.java
2011-06-09 17:42:56 UTC (rev 25693)
@@ -22,6 +22,16 @@
}
public static int countNodes() {
+
+ // igraph_vector_init(&edgesVector, 20);
+ // fillEdgesVector(&edgesVector)
+ // igraph_empty(&graph, 0, 0);
+ // igraph_add_edges(&graph, edgesVector, 0);
+ // int nodesCount = igraph_vcount(&graph);
+ // igraph_vector_destroy(edgesVector);
+ // igraph_destroy(&graph);
+ // return nodesCount;
+
return 0;
}
Added: csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/Makefile
===================================================================
--- csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/Makefile
(rev 0)
+++ csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/Makefile
2011-06-09 17:42:56 UTC (rev 25693)
@@ -0,0 +1,16 @@
+all: libigraphWrapper.dylib
+
+
+libigraphWrapper.dylib: igraphJNA.cpp igraphJNA.h
+ g++ -fPIC -shared -soname,libigraphWrapper.dylib ${CFLAGS} ${LIB_FLAGS}
-o libigraphWrapper.dylib igraphJNA.cpp
+
+clean :
+ rm libIgraphWrapper.dylib
+
+
+CFLAGS=-I${IGRAPH_PATH}/include
+LIB_FLAGS=-L${IGRAPH_PATH}/src/.libs -ligraph
+
+
+IGRAPH_PATH := /Users/gerardohuck/igraph/
+
Added: csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.cpp
===================================================================
--- csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.cpp
(rev 0)
+++ csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.cpp
2011-06-09 17:42:56 UTC (rev 25693)
@@ -0,0 +1,667 @@
+//Author Gang Su
+//[email protected]
+//functions to be exported
+//The purpose of this program, is to port some of the igraph funcions/focus on
community structure detection
+//To cytoscape.
+
+
+
+
+
+
+
+/*include this igraph.h first*/
+#include "igraph.h"
+#include "igraphJNA.h"
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+using namespace std;
+
+
+//Testing passing of an integer
+//Try global variables just in case
+int count = 0;
+
+//use a global graph object
+//Make sure there's only one active graph @ a time to reduce confusions
+igraph_t g;
+
+void createGraph(int edgeArray[], int length){
+
+ igraph_vector_t v;
+ igraph_vector_init(&v, length);
+ for(int i=0; i<length; i++){
+ VECTOR(v)[i] = edgeArray[i];
+ }
+
+ //Create undirected graphs here.
+ //Can be extended to create directed graph.
+ //But the problem is the original graph may contain both
+ //Directed an undirected edges.
+ igraph_create(&g, &v, 0, 0);
+ //cout << "Graph Created";
+ //igraph_bool_t simple;
+ //igraph_is_simple(&g, &simple);
+ //return (bool)simple;
+}
+
+//Boolean, test whether the current graph is simple
+//Can only be called when a graph has been loaded
+// bool isSimple(){
+// igraph_bool_t simple;
+// igraph_is_simple(&g, &simple);
+// return (bool)simple;
+// //return 1;
+// }
+
+// bool isConnected(){
+// igraph_bool_t connected;
+// igraph_is_connected(&g, &connected, IGRAPH_STRONG);
+// return (bool)connected;
+// }
+
+// void simplify(){
+// igraph_simplify(&g, 1, 1);
+// }
+// //////////////////////////////
+// void clusters(int membership[], int csize[], int* numCluster){
+// igraph_vector_t membership_v;
+// igraph_vector_t csize_v;
+// igraph_integer_t numCluster_v = 0;
+
+// igraph_vector_init(&membership_v, 0);
+// igraph_vector_init(&csize_v, 0);
+
+// //last argument is ignored
+// //The problem here is that the length of the array is unknown
+// igraph_clusters(&g, &membership_v, &csize_v, &numCluster_v,
IGRAPH_WEAK);
+
+// *numCluster = (int)numCluster_v;
+
+// //Convert data back
+// for(int i=0; i<igraph_vector_size(&membership_v); i++){
+// membership[i] = VECTOR(membership_v)[i];
+// }
+
+// for(int i=0; i<igraph_vector_size(&csize_v); i++){
+// csize[i] = VECTOR(csize_v)[i];
+// }
+
+// }
+
+// //get nodeCount and edgeCount of the current loaded graph
+// int nodeCount(){
+// return (int)igraph_vcount(&g);
+// }
+
+// int edgeCount(){
+// return (int)igraph_ecount(&g);
+// }
+
+// //Map community algorithms
+// //Note that some community algorithms work only on connected graphs
+// void fastGreedy(int membership[], double* modularity, int csize[], int*
numCluster){
+// igraph_vector_t modularity_v;
+// igraph_matrix_t merges;
+// igraph_vector_t csize_v;
+// igraph_vector_t membership_v;
+
+
+
+// igraph_vector_init(&modularity_v, 0);
+// igraph_matrix_init(&merges, 0, 0);
+// igraph_vector_init(&csize_v, 0);
+// igraph_vector_init(&membership_v, 0);
+
+// igraph_community_fastgreedy(&g, 0, &merges, &modularity_v);
+// igraph_community_to_membership(&merges, igraph_vcount(&g),
igraph_vector_which_max(&modularity_v), &membership_v, &csize_v);
+
+// //need only map modularity, membership, csize and number of clusters
+// for(int i=0; i<igraph_vector_size(&membership_v); i++){
+// membership[i] = VECTOR(membership_v)[i];
+// }
+
+// for(int i=0; i<igraph_vector_size(&csize_v); i++){
+// csize[i] = VECTOR(csize_v)[i];
+// }
+
+// *modularity = igraph_vector_max(&modularity_v);
+// *numCluster = igraph_vector_size(&csize_v);
+// }
+
+// void labelPropagation(int membership[], double* modularity){
+// igraph_vector_t membership_v;
+// igraph_vector_init(&membership_v, 0); //if i don't initialize will give
run time error
+//
//vectors and matrices will be initialized
+// igraph_real_t modularity_v;
+
+// igraph_community_label_propagation(&g, &membership_v, 0, 0, 0);
+// igraph_modularity(&g, &membership_v, &modularity_v, 0);
+
+// //Reset these parameters to avoid mistakes.
+// //*numCluster = 0;
+// //for(int i=0; i<igraph_vector_size(&membership_v); i++){
+// // csize[i] = 0;
+// //}
+
+
+// for(int i=0; i<igraph_vector_size(&membership_v); i++){
+// membership[i] = VECTOR(membership_v)[i];
+// }
+
+// *modularity = modularity_v;
+// //*modularity = 0.0;
+// }
+
+// void walkTrap(int membership[], double* modularity, int csize[], int*
numCluster){
+// igraph_vector_t modularity_v;
+// igraph_matrix_t merges;
+// igraph_vector_t csize_v;
+// igraph_vector_t membership_v;
+
+
+
+// igraph_vector_init(&modularity_v, 0);
+// igraph_matrix_init(&merges, 0, 0);
+// igraph_vector_init(&csize_v, 0);
+// igraph_vector_init(&membership_v, 0);
+
+// //igraph_community_fastgreedy(&g, 0, &merges, &modularity_v);
+// //The default step is 4 steps.
+// igraph_community_walktrap(&g, 0, 4, &merges, &modularity_v);
+
+// igraph_community_to_membership(&merges, igraph_vcount(&g),
igraph_vector_which_max(&modularity_v), &membership_v, &csize_v);
+
+// //need only map modularity, membership, csize and number of clusters
+// for(int i=0; i<igraph_vector_size(&membership_v); i++){
+// membership[i] = VECTOR(membership_v)[i];
+// }
+
+// for(int i=0; i<igraph_vector_size(&csize_v); i++){
+// csize[i] = VECTOR(csize_v)[i];
+// }
+
+// *modularity = igraph_vector_max(&modularity_v);
+// *numCluster = igraph_vector_size(&csize_v);
+// }
+
+// void edgeBetweenness(int membership[], double* modularity, int csize[],
int*numCluster){
+// //The problem of edge betweenness is that
+// //need to calculate modularity for all merges
+// igraph_vector_t modularity_v;
+// igraph_matrix_t merges;
+// igraph_vector_t csize_v;
+// igraph_vector_t membership_v;
+// igraph_vector_t result;
+// igraph_real_t modularity_max;
+
+// igraph_vector_init(&modularity_v, igraph_vcount(&g)-1); //Try to access
items beyond the limit will give array out of bounds exception
+// igraph_matrix_init(&merges, 0, 0);
+// igraph_vector_init(&csize_v, 0);
+// igraph_vector_init(&membership_v, 0);
+// igraph_vector_init(&result, 0);
+
+// igraph_community_edge_betweenness(&g, &result, 0, &merges, 0, 0);
+
+// //set step to 10
+// for(int i=0; i < igraph_vcount(&g)-1 ; i++){
+// igraph_community_to_membership(&merges, igraph_vcount(&g), i,
&membership_v, 0);
+// igraph_modularity(&g, &membership_v, &modularity_max, 0);
+
+// VECTOR(modularity_v)[i] = modularity_max; //assign modularity
vector
+// //VECTOR(modularity_v)[
+// }
+
+
+// igraph_community_to_membership(&merges, igraph_vcount(&g),
igraph_vector_which_max(&modularity_v), &membership_v, &csize_v);
+
+
+// for(int i=0; i<igraph_vector_size(&membership_v); i++){
+// membership[i] = VECTOR(membership_v)[i];
+// }
+
+// for(int i=0; i<igraph_vector_size(&csize_v); i++){
+// csize[i] = VECTOR(csize_v)[i];
+// }
+
+// *modularity = igraph_vector_max(&modularity_v);
+// *numCluster = igraph_vector_size(&csize_v);
+
+
+// //*modularity = 0;
+// }
+
+// void spinGlass(int membership[], double* modularity, int csize[],
int*numCluster){
+// igraph_real_t modularity_v;
+// igraph_matrix_t merges;
+// igraph_vector_t csize_v;
+// igraph_vector_t membership_v;
+// //igraph_vector_t result;
+// //igraph_real_t modularity_max;
+
+// //igraph_vector_init(&modularity_v, 0); //Try to access items beyond
the limit will give array out of bounds exception
+// igraph_matrix_init(&merges, 0, 0);
+// igraph_vector_init(&csize_v, 0);
+// igraph_vector_init(&membership_v, 0);
+// //igraph_vector_init(&result, 0);
+
+// //Possible to change to parameter to make it converge faster
+// igraph_community_spinglass(&g, 0, &modularity_v, 0, &membership_v,
&csize_v, 25, 0, 1.0, 0.1, 0.99, IGRAPH_SPINCOMM_UPDATE_SIMPLE, 1.0);
+
+// //Here
+
+// for(int i=0; i<igraph_vector_size(&membership_v); i++){
+// membership[i] = VECTOR(membership_v)[i];
+// }
+
+// for(int i=0; i<igraph_vector_size(&csize_v); i++){
+// csize[i] = VECTOR(csize_v)[i];
+// }
+
+// *modularity = modularity_v;
+// *numCluster = igraph_vector_size(&csize_v);
+// }
+
+// void spinGlassSingle(int targetNode, int community[], int* community_size){
+// //igraph_real_t modularity_v;
+// //igraph_matrix_t merges;
+// //igraph_vector_t csize_v;
+// //igraph_vector_t membership_v;
+// //igraph_vector_t result;
+// //igraph_real_t modularity_max;
+
+// //igraph_vector_init(&modularity_v, 0); //Try to access items beyond
the limit will give array out of bounds exception
+// //igraph_matrix_init(&merges, 0, 0);
+// //igraph_vector_init(&csize_v, 0);
+// //igraph_vector_init(&membership_v, 0);
+// //igraph_vector_init(&result, 0);
+
+// igraph_vector_t community_v;
+// igraph_vector_init(&community_v, 0);
+
+// igraph_community_spinglass_single(&g, 0, targetNode, &community_v, 0,
0, 0, 0, 25, IGRAPH_SPINCOMM_UPDATE_SIMPLE, 1.0);
+// *community_size = igraph_vector_size(&community_v);
+// for(int i=0; i<igraph_vector_size(&community_v); i++){
+// community[i] = VECTOR(community_v)[i];
+// }
+
+// //return the community surrounding the given vertex
+
+// }
+
+// void leadingEigenvector(int membership[], double* modularity){
+// igraph_matrix_t merges;
+// igraph_vector_t membership_v;
+// igraph_arpack_options_t options;
+
+// //Dosen't really change the outcome.
+// //options.mxiter = 5000000;
+
+// igraph_real_t modularity_v;
+
+// igraph_matrix_init(&merges, 0, 0);
+// igraph_vector_init(&membership_v, 0);
+// igraph_arpack_options_init(&options);
+
+// igraph_community_leading_eigenvector(&g, &merges, &membership_v, -1,
&options);
+// igraph_modularity(&g, &membership_v, &modularity_v, 0);
+
+// *modularity = modularity_v;
+// for(int i=0; i<igraph_vector_size(&membership_v); i++){
+// membership[i] = VECTOR(membership_v)[i];
+// }
+// }
+
+
+// void layoutCircle(double x[], double y[]){
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, 0, 0);
+
+// igraph_layout_circle(&g, &locs);
+
+// long int nRow = igraph_matrix_nrow(&locs);
+// long int nCol = igraph_matrix_ncol(&locs);
+// for(int i=0; i<nRow; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+
+
+// }
+
+
+// void layoutRandom(double x[], double y[]){
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, 0, 0);
+// igraph_layout_random(&g, &locs);
+
+// long int nRow = igraph_matrix_nrow(&locs);
+// long int nCol = igraph_matrix_ncol(&locs);
+// for(int i=0; i<nRow; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+// }
+
+// //This one also needs scaling
+// //Let's actually do scaling in java then, it's liner time anyway
+// void layoutGraphOpt(double x[], double y[], int iter, double nodeCharge,
double nodeMass, int springLength, double springConstant, double maxSaMovement,
bool useSeed){
+
+// //This algorithm can work on a current seting, so will intialize res
with x and y first
+// long int vcount = igraph_vcount(&g);
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, vcount, 2); //2 col, with x and y
+
+// //Res need to be initalized
+// for(int i=0; i<vcount; i++){
+// MATRIX(locs, i, 0) = x[i];
+// MATRIX(locs, i, 1) = y[i];
+// }
+
+// //It will be quite painful to make dialogs to set values for these crap
+// igraph_layout_graphopt(&g, &locs, iter, nodeCharge, nodeMass,
springLength, springConstant, maxSaMovement, useSeed);
+// for(int i=0; i<vcount; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+
+// }
+
+// //still not working
+// void layoutDRL(double x[], double y[], bool useSeed, int mode){
+
+
+// long int vcount = igraph_vcount(&g);
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, vcount, 2);
+// for(int i=0; i<vcount; i++){
+// MATRIX(locs, i, 0) = x[i];
+// MATRIX(locs, i, 1) = y[i];
+// }
+
+// /*
+// igraph_layout_drl_options_t options;
+// if(mode == 1){
+// igraph_layout_drl_options_init(&options,
IGRAPH_LAYOUT_DRL_COARSEN);
+// }
+// else if(mode == 2){
+// igraph_layout_drl_options_init(&options,
IGRAPH_LAYOUT_DRL_COARSEST);
+// }
+// else if(mode == 3){
+// igraph_layout_drl_options_init(&options,
IGRAPH_LAYOUT_DRL_REFINE);
+// }
+// else if(mode == 4){
+// igraph_layout_drl_options_init(&options,
IGRAPH_LAYOUT_DRL_FINAL);
+// }
+// else {
+// igraph_layout_drl_options_init(&options,
IGRAPH_LAYOUT_DRL_DEFAULT);
+// }
+// */
+
+// igraph_layout_drl_options_t options;
+// igraph_layout_drl_options_init(&options, IGRAPH_LAYOUT_DRL_COARSEN);
+
+// //Force directed DRL
+// igraph_layout_drl(&g, &locs, 0, &options, 0, 0);
+
+// //Return
+// for(int i=0; i<vcount; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+
+// }
+
+// ///
+// void layoutFruchterman(double x[], double y[], int iter, double maxDelta,
double area, double coolExp, double repulserad, bool useSeed){
+// long int vcount = igraph_vcount(&g);
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, vcount, 2);
+// for(int i=0; i<vcount; i++){
+// MATRIX(locs, i, 0) = x[i];
+// MATRIX(locs, i, 1) = y[i];
+// }
+
+// igraph_layout_fruchterman_reingold(&g, &locs, iter, maxDelta, area,
coolExp, repulserad, useSeed, 0);
+// for(int i=0; i<vcount; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+// }
+
+// //
+// void layoutKamadaKawai(double x[], double y[], int iter, double sigma,
double initTemp, double coolExp, double kkConsts, bool useSeed){
+// long int vcount = igraph_vcount(&g);
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, vcount, 2);
+// for(int i=0; i<vcount; i++){
+// MATRIX(locs, i, 0) = x[i];
+// MATRIX(locs, i, 1) = y[i];
+// }
+
+// igraph_layout_kamada_kawai(&g, &locs, iter, sigma, initTemp, coolExp,
kkConsts, useSeed);
+// for(int i=0; i<vcount; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+// }
+
+// //Tree like structure
+// void layoutReingoldTilford(double x[], double y[], int root){
+// long int vcount = igraph_vcount(&g);
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, vcount, 2);
+// for(int i=0; i<vcount; i++){
+// MATRIX(locs, i, 0) = x[i];
+// MATRIX(locs, i, 1) = y[i];
+// }
+
+// igraph_layout_reingold_tilford(&g, &locs, root);
+
+// //This is nice, can specify a root
+// for(int i=0; i<vcount; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+
+// }
+
+// //circular
+// void layoutReingoldTilfordCircular(double x[], double y[], int root){
+// long int vcount = igraph_vcount(&g);
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, vcount, 2);
+// for(int i=0; i<vcount; i++){
+// MATRIX(locs, i, 0) = x[i];
+// MATRIX(locs, i, 1) = y[i];
+// }
+
+// igraph_layout_reingold_tilford_circular(&g, &locs, root);
+
+// //
+// for(int i=0; i<vcount; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+
+// }
+
+// //grid
+// void layoutGridFruchtermanReingold(double x[], double y[], int iter, double
maxDelta, double area, double coolExp, double repulserad, double cellSize, bool
useSeed){
+// long int vcount = igraph_vcount(&g);
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, vcount, 2);
+// for(int i=0; i<vcount; i++){
+// MATRIX(locs, i, 0) = x[i];
+// MATRIX(locs, i, 1) = y[i];
+// }
+
+// igraph_layout_grid_fruchterman_reingold(&g, &locs, iter, maxDelta,
area, coolExp, repulserad, cellSize, useSeed);
+
+// for(int i=0; i<vcount; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+
+// }
+
+// //lgl
+// void layoutLGL(double x[], double y[], int maxIt, double maxDelta, double
area, double coolExp, double repulserad, double cellSize, int root){
+// long int vcount = igraph_vcount(&g);
+// igraph_matrix_t locs;
+// igraph_matrix_init(&locs, vcount, 2);
+// for(int i=0; i<vcount; i++){
+// MATRIX(locs, i, 0) = x[i];
+// MATRIX(locs, i, 1) = y[i];
+// }
+
+// igraph_layout_lgl(&g, &locs, maxIt, maxDelta, area, coolExp,
repulserad, cellSize, root);
+
+// for(int i=0; i<vcount; i++){
+// x[i] = MATRIX(locs, i, 0);
+// y[i] = MATRIX(locs, i, 1);
+// }
+
+// }
+
+//
///////////////////////////////////////////////////////////////////////////////
+// //Shortest path function
+
+// //Calculate shortest path as the distance matrix
+// void distMatrix(double dist1d[]){
+
+// //This will just map back the data to dist
+// long nodeCount = igraph_vcount(&g);
+// igraph_matrix_t dist;
+// igraph_matrix_init(&dist,nodeCount, nodeCount);
+
+// igraph_vs_t nodes;
+// igraph_vs_all(&nodes);
+
+// //This idea is to get all the nodes.
+// igraph_shortest_paths(&g, &dist, nodes, IGRAPH_ALL);
+
+// int counter = 0;
+// for(int i=0; i<nodeCount; i++){
+// for(int j=0; j<nodeCount; j++){
+// dist1d[counter] = MATRIX(dist, i, j);
+// counter++;
+// }
+// }
+
+// }
+
+
+
+
+
+
+
+
+//
///////////////////////////////////////////////////////////////////////////////
+// //These are testing functions
+// void nativeArrayTest(int data[]){
+// //try to pass unitialized array
+// //Allocated to a different memory address, the passed array is not
affected.
+// data = new int[10];
+// for(int i=0; i<10; i++){
+// data[i] = i;
+// }
+// }
+
+
+// int nativeCountAdd(int value){
+// count += value;
+// return count;
+// }
+
+
+// //extern "C"{
+// //Simple adding of two integers
+// int nativeAdd( int a, int b )
+// {
+// return( a + b );
+// }
+
+// //Add one to the passed integer via pointer
+// void nativeIncrement(int* iptr){
+// *iptr += 1;
+// //return a;
+// }
+
+// //Reset all the elements in integer array to 0
+// //return the number of operations
+// int nativeArrayReset(int data[], int length){
+// int i;
+// for(i=0; i<length; i++){
+// data[i] = 10;
+// }
+// return i;
+// }
+
+
+// //Try to allocate some memory by malloc
+// //This is the test for,
+// void nativeMemoryAllocate(int **data, int *length){
+// //try that the memory allocation is done in c
+// *length = 10;
+// *data = (int*) malloc (*length * sizeof(int)); //allocate the space for
array of length 10, this is equivalent to initialized the first item in data ...
+
+// for(int i=0; i < *length; i++){
+// //**data = i;
+// //*data++; //move the pointer
+// (*data)[i] = i;
+// }
+
+// //This won't waste array space
+// //For vectors, just need to do a int **data
+// }
+
+// //This is not working very well...need int**data instead of int* data
+// void nativePointerMemoryAllocate(int *data, int *length){
+// *length = 10;
+// data = (int*) malloc ( *length * sizeof(int)); //however, the memory is
not freed. Wonder how long it will persist in memory.
+
+// for(int i=0; i< *length; i++){
+// data[i] = i+10;
+// }
+// }
+
+// void nativeListAllocate(int*** data, int** list_lengths, int* data_length){
+// //data containing pointers
+// *data_length = 2;
+// *list_lengths = (int*) malloc (*data_length * sizeof(int)); //The first
element this pointer is pointing to, and the only one
+
+// //int** data;
+
+
+// //The problem is that data must be pointer to pointers
+// *data = (int**) malloc(*data_length * sizeof(int*));
+
+// //didn't allocate space for the arrays in data
+
+
+// //initialize some list_lengths
+// (*list_lengths)[0] = 3;
+// (*list_lengths)[1] = 4; //Onluy two elements
+
+// //allocate memory for data
+// //When getting a vector it's a lot different than this
+// for(int i=0; i< *data_length; i++){
+// (*data)[i] = (int*) malloc ( (*list_lengths)[i] * sizeof(int));
+// }
+
+
+
+
+// //This way to assign value is funky
+// for(int i=0; i< *data_length; i++){
+// for(int j=0; j < (*list_lengths)[i]; j++ ){
+// ((*data)[i])[j] = i+j*10;
+// }
+// }
+
+// //*data_ref = data;
+// }
Property changes on:
csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.cpp
___________________________________________________________________
Added: svn:executable
+ *
Added: csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.h
===================================================================
--- csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.h
(rev 0)
+++ csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.h
2011-06-09 17:42:56 UTC (rev 25693)
@@ -0,0 +1,36 @@
+//Author Gang Su.
+//[email protected]
+
+
+extern "C"
+{
+ //test functions
+/* int nativeAdd( int a, int b ); */
+/* void nativeIncrement(int* iptr); */
+/* int nativeArrayReset(int data[], int length); */
+/* int nativeCountAdd(int value); */
+/* void nativeArrayTest(int data[]); */
+/* void nativeMemoryAllocate(int **data, int *length); //pointer to pointer
reference */
+/* void nativePointerMemoryAllocate(int *data, int *length); //single
pointer reference */
+/* void nativeListAllocate(int*** data, int** list_lengths, int*
data_length); //Return a zig-zag type */
+/* void nativeMatrixAllocate(int** data, int* nrow, int* ncol); */
+
+ //igraph functions
+ void createGraph(int edgeArray[], int length);
+/* bool isSimple(); */
+/* bool isConnected(); */
+/* void simplify(); */
+/* void clusters(int membership[], int csize[], int* numCluster); */
+/* int nodeCount(); */
+/* int edgeCount(); */
+
+/* void fastGreedy(int membership[], double* modularity, int csize[], int *
numCluster); */
+/* void labelPropagation(int membership[], double* modularity); */
+/* void walkTrap(int membership[], double*modularity, int csize[], int *
numCluster); */
+/* void edgeBetweenness(int membership[], double*modularity, int csize[],
int * numCluster); */
+/* void spinGlass(int membership[], double* modularity, int csize[], int*
numCluster); */
+/* void spinGlassSingle(int target, int community[], int* community_size);
//only compute community close to the target id */
+ //Can also make a function to compute an array of ids, if possible in later
versions.
+
+
+}
Property changes on:
csplugins/trunk/soc/ghuck/IgraphPlugin/src/igraphWrapper/igraphJNA.h
___________________________________________________________________
Added: svn:executable
+ *
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.