public void DepthFirstWalk(DepthFirstHandler inHandler, DepthFirstHandler outHandler, int root, DirectedWalkMode mode, bool includeUnreachableFromRoot = false, object tag = null) { igraph_dfshandler_t inWrapper = (t, vid, dist, extra) => inHandler != null && inHandler(this, vid, dist, tag); igraph_dfshandler_t outWrapper = (t, vid, dist, extra) => outHandler != null && outHandler(this, vid, dist, tag); DllImporter.igraph_dfs(graph, root, (igraph_neimode_t)mode, includeUnreachableFromRoot, null, null, null, null, inWrapper, outWrapper, tag); }
/// <summary> /// Use multi-dimensional scaling to layout vertices. /// A distance matrix can be used to specify the distances between the vertices. /// Otherwise the distances will be calculated by shortest-path-length. /// </summary> /// <remarks> /// For disconnected graphs, dimension must be 2. /// </remarks> /// <param name="dist">The distance matrix to layout the vertices.</param> /// <param name="dim">How many dimensions should be used.</param> /// <returns>The coordinates matrix of the aligned vertices.</returns> public Matrix LayoutWithMds(Matrix dist = null, int dim = 2) { var coords = new Matrix(Vertices, dim); DllImporter.igraph_layout_mds(graph, coords.NativeInstance, dist != null ? dist.NativeInstance : null, dim); return(coords); }
public double Density() { double density; DllImporter.igraph_density(graph, out density, false); return(density); }
public Vector(int length) { if (length < 0) { throw new ArgumentException("Rows and Columns must be >= 0"); } vector = new igraph_vector_t(); DllImporter.igraph_vector_init(vector, length); }
public Matrix(int nrow, int ncol) { if (nrow < 0 || ncol < 0) { throw new ArgumentException("Rows and Columns must be >= 0"); } matrix = new igraph_matrix_t(); DllImporter.igraph_matrix_init(matrix, nrow, ncol); }
public Matrix(Matrix other) { if (other == null) { throw new ArgumentNullException("other"); } matrix = new igraph_matrix_t(); DllImporter.igraph_matrix_copy(matrix, other.NativeInstance); }
public Graph(int vertices, IEnumerable <Tuple <int, int> > edges, bool directed) { graph = new igraph_t(); DllImporter.igraph_empty(graph, vertices, directed); foreach (var e in edges) { DllImporter.igraph_add_edge(graph, e.Item1, e.Item2); } }
public Vector(Vector other) { if (other == null) { throw new ArgumentNullException("other"); } vector = new igraph_vector_t(); DllImporter.igraph_vector_copy(vector, other.NativeInstance); }
public void Dispose() { if (matrix == null) { return; } DllImporter.igraph_matrix_destroy(matrix); matrix = null; GC.SuppressFinalize(this); }
public void Dispose() { if (vector == null) { return; } DllImporter.igraph_vector_destroy(vector); vector = null; GC.SuppressFinalize(this); }
public void Dispose() { if (graph == null) { return; } DllImporter.igraph_destroy(graph); graph = null; GC.SuppressFinalize(this); }
public Matrix LayoutWithFruchtermanReingold(int niter, double startTemp, Matrix initialCoords = null) { if (initialCoords != null && (initialCoords.Rows != Vertices || initialCoords.Columns != 2)) { throw new ArgumentException("Initial coordinate matrix does not contain the required number of rows and columns.", "initialCoords"); } var coords = initialCoords != null ? new Matrix(initialCoords) : new Matrix(Vertices, 2); DllImporter.igraph_layout_fruchterman_reingold(graph, coords.NativeInstance, initialCoords != null, niter, startTemp, igraph_layout_grid_t.IGRAPH_LAYOUT_AUTOGRID, null, null, null, null, null); return(coords); }
public Vector(IEnumerable <double> data) { if (data == null) { throw new ArgumentNullException("data"); } var vec = data.ToArray(); vector = new igraph_vector_t(); DllImporter.igraph_vector_init_copy(vector, vec); }
public Matrix LayoutWithKamadaKawai(int maxiter, double epsilon, double kkconst, Matrix initialCoords = null) { if (initialCoords != null && (initialCoords.Rows != Vertices || initialCoords.Columns != 2)) { throw new ArgumentException("Initial coordinate matrix does not contain the required number of rows and columns.", "initialCoords"); } var coords = initialCoords != null ? new Matrix(initialCoords) : new Matrix(Vertices, 2); DllImporter.igraph_layout_kamada_kawai(graph, coords.NativeInstance, initialCoords != null, maxiter, epsilon, kkconst, null, null, null, null, null); return(coords); }
public Matrix LayoutWithDavidsonHarel(int maxiter, int fineiter, double cool_fact, double weight_node_dist, double weight_border, double weight_edge_lengths, double weight_edge_crossings, double weight_node_edge_dist, Matrix initialCoords = null) { if (initialCoords != null && (initialCoords.Rows != Vertices || initialCoords.Columns != 2)) { throw new ArgumentException("Initial coordinate matrix does not contain the required number of rows and columns.", "initialCoords"); } var coords = initialCoords != null ? new Matrix(initialCoords) : new Matrix(Vertices, 2); DllImporter.igraph_layout_davidson_harel(graph, coords.NativeInstance, initialCoords != null, maxiter, fineiter, cool_fact, weight_node_dist, weight_border, weight_edge_lengths, weight_edge_crossings, weight_node_edge_dist); return(coords); }
public double[,] ToMatrix() { var result = new double[Rows, Columns]; for (var i = 0; i < Rows; i++) { for (var j = 0; j < Columns; j++) { result[i, j] = DllImporter.igraph_matrix_e(matrix, i, j); } } return(result); }
public Vector PageRank(double damping = 0.85, Vector weights = null) { var vec = new Vector(Vertices); var all = new igraph_vs_t(); DllImporter.igraph_vs_all(ref all); try { double eigenv = 0; DllImporter.igraph_pagerank(graph, igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_PRPACK, vec.NativeInstance, out eigenv, all, IsDirected, damping, weights != null ? weights.NativeInstance : null); } finally { DllImporter.igraph_vs_destroy(ref all); } return(vec); }
public double this[int row, int col] { get { if (row < 0 || row > Rows || col < 0 || col > Columns) { throw new IndexOutOfRangeException("Trying to get cell(" + row + ";" + col + ") of matrix(" + Rows + ";" + Columns + ")."); } return(DllImporter.igraph_matrix_e(matrix, row, col)); } set { if (row < 0 || row > Rows || col < 0 || col > Columns) { throw new IndexOutOfRangeException("Trying to set cell(" + row + ";" + col + ") of matrix(" + Rows + ";" + Columns + ")."); } DllImporter.igraph_matrix_set(matrix, row, col, value); } }
public double this[int index] { get { if (index < 0 || index > Length) { throw new IndexOutOfRangeException("Trying to get index(" + index + ") of vector(" + Length + ")."); } return(DllImporter.igraph_vector_e(vector, index)); } set { if (index < 0 || index > Length) { throw new IndexOutOfRangeException("Trying to set index(" + index + ") of vector(" + Length + ")."); } DllImporter.igraph_vector_set(vector, index, value); } }
public Matrix(double[,] mat) { if (mat == null) { throw new ArgumentNullException("mat"); } matrix = new igraph_matrix_t(); var nrows = mat.GetLength(0); var ncols = mat.GetLength(1); DllImporter.igraph_matrix_init(matrix, nrows, ncols); var colwise = new double[ncols * nrows]; for (var j = 0; j < ncols; j++) { for (var i = 0; i < nrows; i++) { colwise[j * nrows + i] = mat[i, j]; } } DllImporter.igraph_vector_init_copy(matrix.data, colwise); }
private static Rect GetMonitorArea(Window imp, bool monitorArea) { var handle = (new WindowInteropHelper(imp)).Handle; var monitor = MonitorFromWindow(handle, MONITOR_DEFAULTTONEAREST); if (monitor != IntPtr.Zero) { var monitorData = new MONITORINFO(); if (DllImporter.GetMonitorInfo(monitor, monitorData)) { Marshal.Release(handle); handle = IntPtr.Zero; } var rect = monitorArea ? monitorData.rcMonitor : monitorData.rcWork; var area = new Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); return(area); } return(new Rect()); }
public void Reverse() { DllImporter.igraph_vector_reverse(vector); }
public void Shuffle() { DllImporter.igraph_vector_shuffle(vector); }
public void SetSeed(uint seed) { DllImporter.igraph_rng_seed(seed); }
public void Fill(double v) { DllImporter.igraph_vector_fill(vector, v); }
public void Transpose() { DllImporter.igraph_matrix_transpose(matrix); }
public void Scale(double by) { DllImporter.igraph_matrix_scale(matrix, by); }
public void Fill(double v) { DllImporter.igraph_matrix_fill(matrix, v); }
public double[] ToArray() { return(DllImporter.igraph_vector_to_array(vector)); }
public void Scale(double by) { DllImporter.igraph_vector_scale(vector, by); }