Graph.edgeSet().toArray() will return a Object[], which cannot be cast to DefaultWeightedEdge[]. Instead use Graph.edgeSet().toArray(new DefaultWeightedEdge[0]).

Here's the way I would solve it, using your code from above to create the g object. This was trickier than at first glance because of the multi-color membership at the group/connectedness/cluster level that you wanted to attain.: ## Find cluster membership: c <- clusters(g) d <- data.frame(membership=c$membership, color=V(g)$color, id=1:length(V(g)))...

algorithm,graph,graph-algorithm,linear-programming,np-complete

It's possible to formulate this as the following problem. Suppose each vertex v in the graph has weight w(v). You define a variable x(v), and use some out-of-the-box linear programming solver to solve max \sum_v w(v) x(v) (maximize the weight of chosen vertices) subject to x(u) + x(v) <= 1,...

This seems like a good fit for the animation package. You could do something like this. First, define a function that can interpolate between the two plots framedata<-function(x) { subset(transform(my_mtcars, x=rand + x*(wt-rand), y=mpg ), select=c(x,y)) } Then you can animate them with library(animation) frame <- seq(0, 1, length.out=20) saveGIF(lapply(frame,...

algorithm,sorting,graph,distance

It can be done with dynamic programming. The graph is a DAG, so first do a topological sort on the graph, let the sorted order be v1,v2,v3,...,vn. Now, set D(v)=0 for all "end node", and from last to first (according to topological order) do: D(v) = max { D(u) +...

string,algorithm,search,graph,tree

It's an interesting problem; usually one would imagine a single tree being searched for a variable set of strings. Here the situation is reversed: the set of strings is fixed and the tree is highly variable. I think that the best you can do is build a trie representing the...

This exact scenario is in the documentation: https://github.com/Readify/Neo4jClient/wiki/cypher-examples#create-a-user

Integer does not implement DoubleSupplier which is the reason why you can't use Integer as second type parameter of Dijkstra. Maybe you actually want to add a ToDoubleFunction<E>, which allows you to map edges to double instead: public class Dijkstra<V, E> { private final ToDoubleFunction<E> edgeToWeightFunction; public Dijkstra(ToDoubleFunction<E> edgeToWeightFunction) {...

graph,neo4j,cypher,relationship

The right way to query this is: MATCH (p:Person)-[:ACTED_IN]->(), (p)-[:FATHER]->() RETURN p You're looking for a :Person node having and ACTED_IN relationship and (since p is used again) having a :FATHER relationship. I'm using anonymous nodes at the other end, since we're not interested in the endpoint - just the...

It is indeed possible, though it is a bit cumbersome. Since Canvas will draw with a fallback font if the actual font it not yet ready, and since fonts are lazy loaded you will need to hold of rendering until the font is ready. This should be possible using something...

Both of your links are to the 'development' part of networkx (check the url), so I don't think it's in the standard release yet. Probably your best option is to copy the relevant code into a file in your working directory and import it separately. Otherwise, look to download the...

r,graph,plot,ggplot2,time-series

Two ways of doing this: If sample data created as follows: Full.df <- data.frame(Date = as.Date("2006-01-01") + as.difftime(0:364, units = "days")) Full.df$Month <- as.Date(format(Full.df$Date, "%Y-%m-01")) Full.df[paste0("Count.", c("S", "G", "W", "F"))] <- matrix(sample(100, 365 * 4, replace = TRUE), ncol = 4) Optimal way using reshape2 package: molten <- melt(Full.df, id.vars...

IIUC, this is the classic Minimum Vertex Cover problem, which is, unfortunately, NP Complete. Fortunately, the most intuitive and greedy possible algorithm is as good as it gets in this case....

algorithm,graph,graph-algorithm

To get an overall result I'll report what I did. I implemented the in the question mentioned algorithm. (Lets call it thigg's algorithm, because noone mentioned a name) Thigg's algorithm: for each node in the graph: if there is a path from src to this node and a path from...

python,numpy,matplotlib,graph,physics

Fixed Equation def E(wt, Q): return np.exp(-x/float(Q)) * ( 1. - (1./2./float(Q))*np.sin(2.* x) ) Your original equation def E(wt, Q): return (np.e**(-x/Q))*(1-(1/2*Q)*np.sin(2*x)) Errors Unused Variables You never use wt BODMAS You don't have a decay parameter set up correctly, so it will oscillate too much. (1/2*Q) when you mean (1/2/Q)...

Replacing the following code: if(movei == (N*N)+1){ return true; } ...with a hardcoded value... if(movei == 62){ return true; } ...gave me a good result after 0.1 seconds. (A field with only three "zeroes" remaining.) So your overall algorithm works. Hint for better looks of the output: #include <iomanip> cout...

if d[v] == d[u] + w(u,v) && (u,v) is not a backedge The condition d[v]==d[u]+w(u,v) is the most important here. If guarantees that this is never a backedge and, moreover, it guarantees that you will never return to the vertex where you have been. Indeed, assume you returned to...

It is because in the method: def addVertex(lbl: Char) = { val vertex = new Vertex(lbl) vertex :: vertices // This does nothing vertex } You don't change the list vertices. You just produce a new list vertex :: vertices, but you throw it immediately away. Please try changing the...

You can draw your own control quite easily. The main thing is the FillPie method, which draws only part of a circle. To change the starting point of the outer ring or the filling direction you need to change the starting and sweep angle in the FillPie call of the...

Probbaly you need this: #include <stdio.h> #define MAXVERTICES 10 int main(void) { int matrix[MAXVERTICES][MAXVERTICES]; for (int i = 0; i < MAXVERTICES; i++) for (int j = 0; j < MAXVERTICES; j++) matrix[i][j] = 0; int nbvertices, nbedges; scanf("%d %d", &nbvertices, &nbedges); for (int i = 0; i < nbvertices;...

algorithm,graph,tree,runtime,big-o

Since everything is still connected and only one edge has been removed, then most (and maybe all) of the spanning tree remains the same. Attempt to construct the same minimum spanning tree, and if the edge that was removed was part of the spanning tree, grab the next smallest edge...

java,algorithm,hadoop,graph,giraph

After looking at some more giraph code examples I found the solution: The Vertex.getEdgeValue() method basically creates a copy of the EdgeValue of the vertex. If you change the object it returns, it won't write these changes back to disk. To save information in the EdgeValue or VertexValue, you have...

algorithm,graph,directed-graph,bfs

you can use the following pseudo-code: ( you can save the distance from the source node in BFS by setting the distance property of each node to father.distance + 1, and the initial node has a distance of 0. also the initial distance for every node is infinite) BFS(G,targetNode), remember...

database,graph,neo4j,cypher,graph-databases

Are you doing this in the web console? I suspect when you do the LIMIT 10000 that the result is just too big to be handled in the web browser. I'm actually a bit surprised that 1000 showed up (again, if you're in the web console). What are you trying...

python,csv,matplotlib,graph,plot

you need to turn x and y into type np.array before you calculate above_threshold and below_threshold, and then it works. In your version, you don't get an array of bools, but just False and True. I added comma delimiters to your input csv file to make it work (I assume...

No, there shouldn't be an infinite cycle. Visited and unvisited nodes in the graph are kept track of, and a visited node will never be visited again. In your example: Mark all nodes as unvisited, except for the starting node which is visited Starting with A, visit B, mark B...

java,algorithm,graph,nodes,dijkstra

Run BFS from the source (let it be s) on the graph to find the length of the shortest path from s to the target t, let it be d. Also mark d(s,v) - the distance from s to any node v. Create a subgraph G'=(V',E') of G such...

Solved using another approach. Code is attached (algorithm is in the code). Some predicates from prev. case remained though (like try_bind). Code at http://pastebin.com/0Eb7qUjS or: % Author: Denis Korekov % Description of algorithm: % G1 is graph 1, G2 is graph 2 % E1 is edge of G1, E2 is...

Based on the following neo4j console http://console.neo4j.org/r/5c2n8h, this query returns you only D as wanted : MATCH (user:User)-[:FRIEND_OF]-(friend) WITH user, collect(friend) AS friends WHERE ALL (f IN friends WHERE f.City = user.City) RETURN user ORDER BY user.City, user.name ...

You also can do a simple barplot: ydf <- ZipGraph barplot(ydf[2,],names.arg = ydf[1,],col=rainbow(ncol(ydf)), xlab="zipcode",ylab="Temperature",cex.axis = .8,cex.names = .7) Edit: Or you can do ylims=c(0,max(ydf[,2])*1.2) y1=barplot(ydf[,2],col=rainbow(nrow(ydf)),xaxt="n",ylim=ylims, xlab="zipcode",ylab="Temperature",cex.axis = .8) axis(1, at=y1,labels=ydf[,1],las=2,cex.axis= .6) ...

I strongly believe each graphing library uses its own "visual guidelines" (that might very well be undocumented) to determine a larger or a smaller "margin" around data. A good formula to calculate viewing area from data range (considering only Y axis) would be, in pseudocode: var margin = 0.1; (ten...

javascript,svg,d3.js,graph,charts

This isn't possible with D3. The axis component will generate an axis that corresponds to the associated range, i.e. to make it any particular size, you have to modify the output range of the associated scale. You can do this quite easily in a responsive manner though by computing the...

java,collections,graph,hashmap

I've just tested with 3.2.1 version and public static void main(String[] args) { class MappedValue { public MappedValue(String id, boolean touched) { identifier = id; this.touched = touched; } private String identifier; private boolean touched; @Override public String toString() { return "MappedValue [identifier=" + identifier + ", touched=" + touched...

One issue is this in your main program: graph->edge[i].s=v1-1; You created a single edge. If i is greater than 0, then this is an out-of-bounds access. Look how you created edge in the create function: graph->edge=(struct Edge*)malloc(sizeof (struct Edge)); That allocation holds a single edge, not multiple edges. Given how...

Try dynamic programming - start from the last level and go backwards. For each node v compute the sum S[v] for the paths from this node to the last level. For the last level this S[v] = 0 for all v. If you have the S[v] for all nodes in...

c++,class,c++11,data-structures,graph

I advise you to use a Link structure, to represent an edge in the graph: struct Link { Node *N; float weight; } Then each Node can contain vector<Link> neighbors; This way there is no duplication of Nodes. There is a duplication of weights, since if Node A has a...

Here is the graph I propose: Two kinds of vertices: departure vertex: airport+departure time arrival vertex: airport + arrival time. Two kind of edges: flight edge: from a departure vertex to an arrival vertex wait edge: from an arrival vertex to a departure vertex of later time in the same...

Your problem is easily reduced to a well-known minimum-cost flow problem: The minimum-cost flow problem (MCFP) is to find the cheapest possible way of sending a certain amount of flow through a flow network. This reduction can be done the following way. Add a dummy "source" and "sink" vertices to...

Change the vertex container selector to setS changes the vertex descriptor into a type that is not streamable. You should, as with many many other algorithms in BGL, pass a separate vertex index: IN: VertexAndEdgeListGraph& g A directed or undirected graph. The graph's type must be a model of VertexAndEdgeListGraph....

algorithm,memory,graph,compiler-optimization,directed-acyclic-graphs

Actually, in some sense this problem is easier than the graph coloring problem, because the decision version of this problem is a special case of the decision version of the Combined Register Allocation and Instruction Scheduling Problem (CRISP), which is simpler to solve than the graph coloring problem (at least...

python,numpy,matplotlib,graph,plot

You can use the condition z=='some tag' to index the x and y array Here's an example (based on the code in your previous question) that should do it. Use a set to automate the creation of tags: import csv import datetime as dt import numpy as np import matplotlib.pyplot...

Basically you can model it using each city/airport as a node and the flights as the connections in between. The weight of the connections/flights is then the time. If you assume that all stopovers are 30 minutes (in a simplified model) then you can add an additional cost per visited...

python,matplotlib,graph,plotly

Found out as of 5/27/15 Plot.ly does not currently support candle stick.

Your graph is undirected, which means that the backedge (0,2) is also taken. Try changing undirectedS to directedS To avoid reporting vertices discovered from additional roots, you could adjust the visitor to detect when the first root is done: Live On Coliru #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graphviz.hpp> #include <boost/graph/depth_first_search.hpp> #include <boost/graph/visitors.hpp>...

It sounds like you’re taking the shortest path from wherever you find yourself currently, and not calculating the total distance to get to a node. Let’s step through it in detail. Dijkstra’s algorithm sets up two sets of nodes: visited (with known distances) and unvisited (with tentative distances). We start...

python,graph,networkx,dijkstra

The problem is that you have to write the word "weight" for assigning it to an edge. You are giving labels to the edges but no weights. The next code works printing 9 when you calculate the distance between nodes A and C. import networkx as nx G = nx.MultiDiGraph()...

The problem is likely here: if (used.find(to)->second != from) { If to is not in used, used.find() will return used.end(), which you then dereference. It is undefined behavior to dereference the end() iterator, which in this case manifests by giving you a runtime error. You have to check the iterator...

java,graph,neo4j,cypher,spring-data-neo4j

How about MATCH (node) WHERE ALL (x IN ['tag1','tag2'] WHERE x in node.tags) RETURN node See http://neo4j.com/docs/2.2.2/query-predicates.html...

algorithm,graph,graph-algorithm

If you allow preprocessing, there is a fast method: Construct the bridge-block forest, whose vertices are 2-connected components, and whose edges are bridges. (It's a tree if the graph is connected.) When you add an edge, if this connects points in the same 2-connected component, nothing happens. If you connect...

You have adjacency matrix in which row.names and col names are your genes. Then you should convert this matrix file to an edge list file: graph_adj=as.data.frame(as.table(as.matrix(net))) write.table(graph_adj, "graph_adj.txt", sep="\t") Now you can open the file in excel, edit it and finally import to cytoscape....

algorithm,graph,tree,runtime,big-o

Don't know if your algorithm is correct, but it doesn't seem O(|V|) at least, because getting the "smallest edge not in T" of a vertex cannot be done in O(1). The most usual way to add an edge e=(u, v) into a MST T is: Run a BFS in T...

algorithm,graph,graph-algorithm,minimum-spanning-tree

I would suggest you to do something like the second answer in the given question: This is prim's algorithm : Start by picking any vertex to be the root of the tree. While the tree does not contain all vertices in the graph find shortest edge leaving the tree and...

May be you should take a look here http://en.wikibooks.org/wiki/OpenGL_Programming/Scientific_OpenGL_Tutorial_01 There is good information to start drawing curves. Because you have a parametrized curve, just store your x,y in a vertex buffer object (VBO) with a size of the number of points you want on your curve and draw that VBO...

api,azure,graph,azure-active-directory,graph-api-explorer

In graph API, "applications" represent application configuration that developers register in their tenant. Gallery apps are no different (and happen to be registered in a special tenant). When you acquire an application (like a gallery app, or consent to a custom application someone else has developed), an application instance gets...

c#,algorithm,data,graph,statistics

A simple way is to calculate the difference between every two neighbouring samples, eg diff= abs(y[x point 1] - y[x point 0]) and calculate the standard deviation for all the differences. This will rank the differences in order for you and also help eliminate random noise which you get if...

python,graph,dataframes,networkx

You could use B.add_weighted_edges_from( [(row['domain'], row['subdomain'], 1) for idx, row in df.iterrows()], weight='weight') to add weighted edges, or you could use B.add_edges_from( [(row['domain'], row['subdomain']) for idx, row in df.iterrows()]) to add edges without weights. You may not need weights since the node degree is the number of edges adjacent to...

java,data-structures,graph,tree,edge

You need to add a method for disconnecting a child from a parent node. That would look something like this: private void disconnectChild(Node child) { children.remove(child); } You would then call this method from your disconnect() method like so: private void disconnect() { if (parent != null) { parent.disconnectChild(this); parent...

r,graph,igraph,connected-components

You can use the results from clusters to subset your nodes according to the cluster size. library(igraph) # example graph set.seed(1) g <- erdos.renyi.game(20, 1/20) V(g)$name <- letters[1:20] par(mar=rep(0,4)) plot(g) # get cluster cl <- clusters(g) cl # $membership # [1] 1 2 3 4 5 4 5 5 6...

java,algorithm,graph,graph-algorithm,depth-first-search

Switch 4 : Toggles all numbers that have modulus 1 with 3 1 % 3 = 1 4 % 3 = 1 7 % 3 = 1 10 % 3 = 1 Switch #1: 0000000000 <- Switch #2: 0101010101 <- Switch #3: 1010101010 Switch #4: 0110110110 <-...

Or you could place a rectangle on the region of interest: rect(xleft=1994,xright = 1998,ybottom=range(CVD$cvd)[1],ytop=range(CVD$cvd)[2], density=10, col = "blue") ...

Setting the strokeStyle will persist. If you set strokeStyle='#ff0000' then all strokes after that will be red until you reset the strokeStyle to some other color. In your case, you might draw the entire grid in black and then draw your midline in red. BTW, you have a typo on...

This can be reduced to Shortest Path Problem: Find the shortest path from v to u, then the shortest cycle that contains (u,v), is v->...->u->v, where v->...->u is the shortest path from v to u as found by the shortest path algorithm. It can be solved efficiently using Dijkstra's Algorithm,...

graph,neo4j,cypher,nodes,relationship

To find all pairs of people having two, differently directed LOVE relationships in between: MATCH (a)-[:LOVE]->(b)<-[:LOVE]-(a) WHERE id(a)<id(b) RETURN a,b order by a.name The WHERE condition here makes sure that a and b do not change roles in a subsequent iteration....

If and only if, at some point during kahn's algorithm has no source to choose (and the remaining graph is still none empty), there is a cycle Proof: Direction1 <--: If there is a cycle, let it be v1->v2->v3->vk->v1. At each step of the algorithm, none of v1,v2,...,vk is a...

python,dictionary,graph,hypercube

Python dictionaries have no defined order, so you'll need to use collections.OrderedDict. Here's an example: from collections import OrderedDict def one_more_one(s): for i, digit in enumerate(s): if digit == '0': yield s[:i] + '1' + s[i+1:] bin_string = ['000', '100', '010', '001', '110', '101', '011', '111'] weights = [[-5, -13,...

algorithm,graph,shortest-path,bfs

Consider a graph like this: A---(3)-----B | | \-(1)-C--(1)/ The shortest path from A to B is via C (with a total weight of 2). A normal BFS will take the path directly from A to B, marking B as seen, and A to C, marking C as seen. At...

python,graph,beautifulsoup,label,networkx

You can convert the list, idvalue to dict using list comprehensions and dict() function labels = dict( [ value for value in enumerate(idvalue) ] ) Example >>> lst = ['a', 'b', 'c', 'd'] >>> dict([ x for x in enumerate(lst) ]) {0: 'a', 1: 'b', 2: 'c', 3: 'd'} Note...

The simplest solution is to set a tension: The green curve is drawn with the default tension, the blue one set a tension of 0.1f: private void panel1_Paint(object sender, PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.DrawLines(Pens.Red, points.ToArray()); e.Graphics.DrawCurve(Pens.Green, points.ToArray()); e.Graphics.DrawCurve(Pens.Blue, points.ToArray(), 0.1f); } You will need to test what is...

Firstly, it doesn't compile with vecS for the VertexContainer: To create a graph and subgraphs, first create the root graph object. Here we use adjacency_list as the underlying graph implementation. The underlying graph type is required to have vertex_index and edge_index internal properties, so we add an edge index property...

A simple way would be to use layout(): layout(mat=matrix(c(1,1,1,2,3,4), ncol=3, byrow=TRUE)) image(matrix(1:100, nrow=100), main="my wide plot", axes=FALSE) plot(rnorm(120), rnorm(120), main="plot 1") plot(dpois(0:20, lambda=6), type="b", , main="plot 2") x = rnorm(100) y = x+runif(100, 10, 12) plot(x=x, y=y, main="plot 3") (For a nice example of a much more sophisticated layout, see...

You would have to create dummy values, for example the table below: A B 1 5 2 4 3 3 4 2 5 1 -1 -5 -2 -4 -3 -3 -4 -2 -5 -1 would produce the following graph: You would have to decide how to transform your values, whether...

javascript,d3.js,graph,data-visualization,force-layout

You're setting the x and y attributes on the g elements to change their positions -- this won't do anything. You need to set the transform attribute instead, like you're doing when adding the g elements. So your tick handler function would contain node.attr("transform", function(d) { return "translate(" + d.x...

The cause is here: layout.show(nf) par(mar = c(3, 3, 1, 1)) # <-- Here plot(x, y, xlim = xrange, ylim = yrange, xlab = 'Hello X-axis', ylab = 'Hello Y-axis', ...) The margins are changed to a small value thus the labels are not in the plot, they are outside...

graph,apache-spark,vertices,edges,spark-graphx

Try: edges.intersection(edges.map(e => Edge(e.dstId, e.srcId)) Note that this compares the Edge.attr values as well. If you want to ignore attr values, then do this: edges.map(e=> (e.srcId,e.dstId)).intersection(edges.map(e => (e.dstId, e.srcId))) ...

Using mtext is not so good but maybe! op=par( mfrow = c( 1, 2 ), oma = c( 1.3, 0, 0, 0 ) ) plot(rnorm(120), rnorm(120)) plot(rnorm(120), rnorm(120)) mtext("Legend that covers both plots", side=1, cex=1.5, col="red",outer = T, xpd=TRUE) mtext("Legend that covers both plots", line = -3,cex=1.5, col="red",outer = T)...

You need to change this constraint: # Terminal vertexes constraints s.t. Pconstraint{i in P: i != 1}: sum{(i,j) in E} x[i,j] - sum{(k,i) in E} x[k,i] = -1; That's because the first node is where flows from in this flow based formulation....

python,sql,r,graph,connected-components

In R, you could use the package igraph: library(igraph) gg <- graph.edgelist(as.matrix(d), directed=F) split(V(gg)$name, clusters(gg)$membership) #$`1` #[1] "a" "b" "c" "u" "e" # #$`2` #[1] "f" "g" "h" "j" # #$`3` #[1] "z" "y" And you can look at the graph using: plot(gg) This is based on an excellent answer...

You can put the categories in the desired order by converting COS to a factor: df$COS = factor(df$COS, levels=c("A","D","C","B")) ...

This problem is called Maximum Cut. Unfortunately it's NP-hard, so don't expect a fast algorithm for large instances.

graph,graph-databases,orient-db,gremlin

It took 5hours but I found the query that does it: The groupBy mapping basically takes as a key the Text node {it} and as a value the leaf from text->parent->sibling {it.inE.outV.outE.inV.hasNot('@class','Text').except([v])} that is not of class Text except for the Input. The last line m.sort{a,b -> b.value.size() <=> a.value.size()}...

If you are sending an image, you must send an image. Not an image in the middle of HTML. If you want to embed the image in HTML, you need to use a normal img tag to do this. If this file is graph.php then remove all HTML tags from...

Lets think different ! Actually, we can say it is a custom progress bar. I never done anything like this before, but I would check the source code of the original progress bar. From this code, I could understand who they drawing thefilling effect` on Android. You need to apply...

image,matlab,user-interface,graph,plot

So figured it i had to write the handles of the GUI to the workspace in the opening function of the gui % --- Executes just before VR_gui is made visible. function VR_gui_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure...

Please see this issue on github. It contains a temporary fix while we work on the official fix. Thanks!...

Instead of using xlabel and ylabel, you may want to go with set label. For example, #!/usr/local/bin/gnuplot datafile='tmp.dat' # file to plot set xlabel " " # no x-label set ylabel " " # no y-label # assuming all plots have same x and y range set xrange [-2:2] set...

The first optimization is to read the whole file in memory in one shot. Accessing memory in the loops will be faster than calling fread. The second optimization is to do less arythmetic operations, even if it means more code. Third optimization is treating the data from file as characters...

This looks like a modified multi-agent path planning problem. Normally agents are just restricted not to collide or cross paths, but in your version they cannot share vertices anywhere. It wouldn't be hard to modify the CBS algorithm to solve this problem. I'm going to call your k paths agents...

Not sure what kind of difficulties do you have any? If just with drawing, so there is one way: @interface ArcView () @property (nonatomic) double arcAngel; @end @implementation ArcView - (void)drawRect:(CGRect)rect { [super drawRect:rect]; CGPoint center = CGPointMake(CGRectGetWidth(self.bounds) / 2, CGRectGetHeight(self.bounds) / 2); double lineWidth = 10; double radius =...

java,android,user-interface,graphics,graph

This link contains a class plot2d.java which was written by importing Canvas http://www.ankitsrivastava.net/2012/03/a-simple-2d-plot-class-for-android/ When you download the file the class is found in GraphButton\GraphButton\src\com\android\graphbutton The file should give you a clear way of implementing the 2D chart....

c,graph,segmentation-fault,edge,adjacency-matrix

Your initialization function is initializing the matrix incorrectly: g->mat = calloc(max, sizeof(double*)); for (i = 0; i < max; i++) g->mat = calloc(max, sizeof(double)); Note that each iteration of the loop is recording the resulting pointer in the same (wrong) place: g->mat. The quickest way to fix it would be...

You may use a recursive procedure, e.g.: for (int i=0;i<Points.Count;i++) { // Paths[i] contains all paths from start to Point[i] Paths.Add(new List<List<list<int>>>()) ; } int startIndex= ... ; int targetIndex=... ; ProcessPoint(startIndex) ; That's all: you will get in Paths[startIndex] all possible paths. Select those ending at target. The recursive...

You should be able to surround everything with a loop. You need to select all the elements with the same class into an array, then loop through that array. I also suggest setting the "el" variable inside the array, then you don't have to change your code: var graphs =...

c++,vector,graph,dijkstra,shortest-path

looks like you have two types: heap_node, and a node class. I'm not sure which type is adj, but either way, you cannot make the vector type an instance. it has to be a type. So either make it typedef struct heap_node HEAP_NODE_STRUCT vector<HEAP_NODE_STRUCT> or c hange the heap_node struct...

c++,boost,graph,boost-graph,graph-coloring

Hehe. This is gonna be the third boost bug to report today. The dimacs parsing code looks truly evil to me. The interface is very inconvenient and the implementation... Well, as you found it's very wrong: In read_edge_line there is this loop: if ('e' == linebuf[0]) { while (*tmp !=...

To find this out, you just need to run simple DFS or BFS algorithm on one of the nodes, it'll find all reachable nodes within a continuous component of the graph, so you just mark it down if you've found the other node during the run of algorithm.

java,oop,graph,uml,software-engineering

I wouldn't make it a method of the Graph (it's not a property of the graph). I would prefer the isParallelTo, since you have to have instances of Edge anyway and there seems to be no need for a static method (it's quite similar to the equals() or compareTo() methods)....

You have to apply Bellman-Ford Algorithm.Wikipedia has proper pseudocode. If you apply this properly your problem will be solved. function BellmanFord(list vertices, list edges, vertex source) ::distance[],predecessor[] // This implementation takes in a graph, represented as // lists of vertices and edges, and fills two arrays // (distance and predecessor)...

In set theory notation |A| is the cardinality of set A, in other words the number of elements contained in set A. For Reference: http://www.mathsisfun.com/sets/symbols.html...