graph-theory

Building or Finding a "relevant terms" suggestion feature.

Given a few words of input, I want to have a utility that will return a diverse set of relevant terms, phrases, or concepts. A caveat is that it would need to have a large graph of terms to begin with, or else the feature would not be very useful. For example, submitting "baseball" would return ["shortstop", "Babe Ruth", "foul ball",...

Guaranteeing Unique Surrogate Key Assignment - Maximum Matching for Non-Bipartite Graph

I am maintaining a data warehouse with multiple sources of data about a class of entities that have to be merged. Each source has a natural key, and what is supposed to happen is that one and only one surrogate key is created for each natural key for all time. If one record from one source system with a particular natural key represent...

Matrix operations to enumerate all paths through n-partite graph

I have an n-partite (undirected) graph, given as an adjacency matrix, for instance this one here: a b c d a 0 1 1 0 b 0 0 0 1 c 0 0 0 1 d 0 0 0 0 I would like to know if there is a set of matrix operations that I can apply to this matrix, which will result in a matrix that "lists" all paths (of length n, i.e. through all the partit...

Seeking algorithm to invert (reverse? mirror? turn inside-out) a DAG

I'm looking for an algorithm to "invert" (reverse? turn inside-out?) a DAG: A* # I can't ascii-art the arrows, so just / \ # pretend the slashes are all pointing B C # "down" (south-east or south-west) / / \ # e.g. G E D # A -> (B -> G, C -> (E -> F, D -> F)) \ / F ...

Finding the most optimal 2x2 matches between heterogeneous collections

I've got a problem: I have a class A and a class B, whose instance objects can be inspected programatically to be similar or different from one another in varying amounts. For instance they may match perfectly, or be quite different (even though the classes are different, they can still represent the same information and be scored iden...

Asymtotic run time needed to compute the transitive closure of a graph?

The transitive closure of a graph is defined e. g. here: http://mathworld.wolfram.com/TransitiveClosure.html It is easily possible in O(n^3), where n is the number of vertices. I was wondering if it can be done in time O(n^2). Thanks in advance ...

What are some examples of problems that are best solved with graphs?

After reading Stevey Yegge's Get That Job At Google article, I found this little quote interesting: Whenever someone gives you a problem, think graphs. They are the most fundamental and flexible way of representing any kind of a relationship, so it's about a 50–50 shot that any interesting design problem has a graph involved in it. M...

Finding the smallest subtree

Given a graph of n nodes that are all interconnected on a coordinate plane, what's the best way to find a subtree of minimal distance that contains m nodes? The only solution I've found to this problem is to generate all combinations of the nodes to connect and attempt to connect these nodes via either Kruskal's or Prim's algorithm whil...

Prim's Algorithm Time Complexity

I was looking at the Wikipedia entry for Prim's algorithm and I noticed that its time complexity with an adjacency matrix is O(V^2) and its time complexity with a heap and adjacency list is O(E lg(V)) where E is the number of edges and V is the number of vertices in the graph. Since Prim's algorithm is used in denser graphs, E can appro...

Looking for open source graph (as in data structure) database engine

I'm writing an application that manipulates some sort of social network data, so the ideal underlying data structure is weighted directed graph. I'd like to do the manipulation (and searching) directly on the data, without first loading the entire graph into memory and serializing after. This could be simulated using a standard SQL data...

How do I guarantee that a DAG stays acyclic after insertion of a node?

I have a DAG storing the relation between certain objects in my application. When this structure is updated by adding a new vertex below an existing one (i. e., implicitly creating a new edge into the new vertex) and then (at any later time) a new edge from there to other vertices, I want to ensure that the graph stays a DAG, i. e. that ...

How to design an approximate path solution?

Hello everyone. I am attempting to write (or expand on an existing) graph search algorithm that will let me find the path to get closest to destination node considering there is no guarantee that the nodes will be connected. To provide a realistic application of this, let's say I need to get from Brampton, Ontario to Hamilton, Ontario....

Visit all nodes in a graph with least repeat visits.

Hi. I have a tile based map where several tiles are walls and others are walkable. the walkable tiles make up a graph I would like to use in path planning. My question is are their any good algorithms for finding a path which visits every node in the graph, minimising repeat visits? For example: If the bottom yellow tile is the st...

Good intro to directed graphs etc.

I'm very interested in mindmaps, treeviews, and the like, but have no training in graph theory / directed graphs etc. What books (and/or websites) would be the best place to start? (Targeting someone with minimal calculus background, but generally good at math, data modeling, and theory). ...

If I topologically sort a DAG, can I drop half the adjacency matrix?

I think I have understood a particular situation as described below, but I lack the theoretical knowledge to conduct a proof and I couldn't find any source that mentions it. If my understanding is correct, I can save half the space on my adjacency matrix, if it isn't I'm likely to have pretty weird bugs. So I'd like to be sure, and I'd a...

shortest path in hash map

The following is a data set I have stored in a hash map, and I have to find the shortest path between two values. 9244, 4322, 4886, 5989, 8598, 9979, 1447, 9657 8598, 6752, 7146, 1951, 660, 1447, 7779 568, 1951, 4886, 2570, 9026, 9489, 7779 6752, 3424, 1977, 4746, 9657 77 The key value of the hash map is the first value of each line, ...

How do I construct the biadjacency matrix of a DAG?

For a bipartite graph, you can substitute the adjacency matrix with what is called its biadjacency matrix: The adjacency matrix A of a bipartite graph whose parts have r and s vertices has the form A = O B BT O where B is an r × s matrix and O is an all-zero matrix. Clearly, the matrix B uniquely represents the...

How do I find the shortest path that covers all nodes in a directed cyclic graph?

I need an example of the shortest path of a directed cyclic graph from one node (it should reach to all nodes of the graph from a node that will be the input). Please if there is an example, I need it in C++, or the algorithm. Thanks very much......... ...

Graph navigation with C#

I having a bit of a quandry trying to come up with a good algorithm to navigate the following graph. If a user chooses "Table 21" as a starting point, I need to be able to get the path to any other table from that starting table. EX: If the user chooses "Table 21" as a start and then adds a value from "Table 8", I need to create the ...

Suggestions for KSPA on undirected graph

Hello Group, There is a custom implementation of KSPA which needs to be re-written. The current implementation uses a modified Dijkstra's algorithm whose pseudocode is roughly explained below. It is commonly known as KSPA using edge-deletion strategy i think so. (i am a novice in graph-theory). Step:-1. Calculate the shortest path bet...