graph-theory

how to connect edges to nodes in a image using minimum spanning tree approach

混江龙づ霸主 提交于 2020-01-15 01:53:40
问题 I am doing my project on graph matching in hand written image, i want to represent a given word image in graph, am using the below algorithm Algorithm: input: Binary image B, Grid width w, Grid height h Output: Graph g = (V, E) with nodes V and edges E 1: function Grid(B,w,h) 2: for i ← 1 to number of columns C = Width of B/w do 3: for j ← 1 to number of rows R = Height of B/h do 4: V = V ∪ {(xm, ym) | (xm, ym) is the centre of mass of segment sij} 5: for Each pair of nodes (u, v) ∈ V × V do

I need an algorithm to get the chromatic number of a graph

本秂侑毒 提交于 2020-01-14 14:19:46
问题 Given the adjacency matrix of a graph, I need to obtain the chromatic number (minimum number of colours needed to paint every node of a graph so that adjacent nodes get different colours). Preferably it should be a java algorithm, and I don't care about performance. Thanks. Edit: recently introduced a fix so the answer is more accurately. now it will recheck his position with his previous positions. Now a new question comes up. Which will be better to raise his 'number-color'? the node in

I need an algorithm to get the chromatic number of a graph

微笑、不失礼 提交于 2020-01-14 14:19:09
问题 Given the adjacency matrix of a graph, I need to obtain the chromatic number (minimum number of colours needed to paint every node of a graph so that adjacent nodes get different colours). Preferably it should be a java algorithm, and I don't care about performance. Thanks. Edit: recently introduced a fix so the answer is more accurately. now it will recheck his position with his previous positions. Now a new question comes up. Which will be better to raise his 'number-color'? the node in

Are there any R Packages for Graphs (shortest path, etc.)?

◇◆丶佛笑我妖孽 提交于 2020-01-13 09:57:27
问题 I know that R is statistical pkg, but probably there is library to work with graphs and find shortest path btw 2 nodes. PS actually, I've found igraph and e1071, which one is better? Thank you 回答1: Sure, there's a Task View that gathers a fair number of the graph-related Packages. (The page linked to is a CRAN portal, which uses iframes, so i can't directly link to the Graph Task View. So from the page linked to here, click on Task Views near the top of the LHS column, then click on the Task

Undirected graph conversion to tree

北慕城南 提交于 2020-01-12 05:39:05
问题 Given an undirected graph in which each node has a Cartesian coordinate in space that has the general shape of a tree, is there an algorithm to convert the graph into a tree, and find the appropriate root node? Note that our definition of a "tree" requires that branches do not diverge from parent nodes at acute angles. See the example graphs below. How do we find the red node? 回答1: here is a suggestion on how to solve your problem. prerequisites notation: g graph, g.v graph vertices v,w,z :

Update minimum spanning tree with modification of edge

流过昼夜 提交于 2020-01-11 15:28:37
问题 A graph (positive weight edges) with a MST If some edge, e is modified to a new value, what is the best way to update the MST without completely remaking it. I think this can be done in linear time. Also, it seems that I would need a different algorithm based on whether 1) e is already a part of the MST and 2) whether the new edge, e is larger or smaller than the original 回答1: There are 4 cases: Edge is in MST and you decreasing value of edge: Current MST is still MST Edge is not in MST and

Secret santa algorithm

梦想的初衷 提交于 2020-01-09 06:18:50
问题 Every Christmas we draw names for gift exchanges in my family. This usually involves mulitple redraws until no one has pulled their spouse. So this year I coded up my own name drawing app that takes in a bunch of names, a bunch of disallowed pairings, and sends off an email to everyone with their chosen giftee. Right now, the algorithm works like this (in pseudocode): function DrawNames(list allPeople, map disallowedPairs) returns map // Make a list of potential candidates foreach person in

Secret santa algorithm

泄露秘密 提交于 2020-01-09 06:18:12
问题 Every Christmas we draw names for gift exchanges in my family. This usually involves mulitple redraws until no one has pulled their spouse. So this year I coded up my own name drawing app that takes in a bunch of names, a bunch of disallowed pairings, and sends off an email to everyone with their chosen giftee. Right now, the algorithm works like this (in pseudocode): function DrawNames(list allPeople, map disallowedPairs) returns map // Make a list of potential candidates foreach person in

Recursive graph traversal: how to generate and return all paths?

陌路散爱 提交于 2020-01-06 13:59:47
问题 Here is my code right now: hasht= {"A":["B", "D", "E"], "B":["C"], "C":["D", "E"], "D":["C", "E"], "E":["B"]} paths=[] def recusive(start, finish, val): if start==finish and val!=1: return start else: for i in hasht[start]: path= start+ recusive(i,finish,2) paths.append(path) print (recusive("C","C",1)) print paths Desired output: [CDC, CDEBC, CEBC] I am trying to generate a table like the one above, but I am running into a problem where the string and the array are not being concatenated.

Recursive graph traversal: how to generate and return all paths?

一个人想着一个人 提交于 2020-01-06 13:59:10
问题 Here is my code right now: hasht= {"A":["B", "D", "E"], "B":["C"], "C":["D", "E"], "D":["C", "E"], "E":["B"]} paths=[] def recusive(start, finish, val): if start==finish and val!=1: return start else: for i in hasht[start]: path= start+ recusive(i,finish,2) paths.append(path) print (recusive("C","C",1)) print paths Desired output: [CDC, CDEBC, CEBC] I am trying to generate a table like the one above, but I am running into a problem where the string and the array are not being concatenated.