graph-theory

Create Mathematica/Combinatorica graph with edges that have named vertices

How do I make a Mathematica graph from edges with named vertices? EG: http://pastebin.com/Se1Nhe3M I've tried the above and several variations, but Combinatorica never quite accepts it right. Apparently, Graph[] wants coordinate positions, which I want Combinatorica to figure out itself. AddVertex to EmptyGraph[0] (or whatever) a...

Graphs - find common data

Hi! I've just started to read upon graph-teory and data structures. I'm building an example application which should be able to find the xpath for the most common links. Imagine a Google serp, my application should be able to find the xpath for all links pointing to a result. Imagine that theese xpaths were found: /html/body/h2/a /ht...

implimenting set theory operations in php

Does anyone have any examples or know of any resources that show how to implement set theory operations in pure php? ...

Shortest path on a graph where distances change dynamically? (maximum energy path)

I'm trying to find the shortest path between two maxima on a discrete energy landscape whereby the shortest path is that which reduces the least in height over the course of the total path. Probably maximum energy path is more correct terminology, but in other words even if a path travels a long distance around the landscape but does no...

Data structures for huge graphs in C++

I want to understand how huge graphs can be implemented, so that graph algorithms run faster with huge graphs. ...

Recreate sets from combinations of these sets

hi, I came across a specific problem and looking for some algorithm for it. The problem to solve is as described below. Let's say we have combinations like below 1 - 3 - 5 1 - 4 - 5 1 - 8 - 5 2 - 4 - 5 3 - 4 - 5 2 - 4 - 7 These combinations were generated from given sets, in this particular case let's say from {1},{3,4,8},{5} ...

General purpose algorithm for triangulating an undirected graph?

I am playing around with implementing a junction tree algorithm for belief propagation on a Bayesian Network. I'm struggling a bit with triangulating the graph so the junction trees can be formed. I understand that finding the optimal triangulation is NP-complete, but can you point me to a general purpose algorithm that results in a 'g...

digraph partitioning to subgraphs

Hello Given a DAG with |V| = n and has s sources we have to present subgraphs such that each subgraph has approximately k1=√|s| sources and approximately k2=√|n| nodes. If we define the height of the DAG to be the maximum path length from some source to some sink. We require that all subgraphs generated will have approximately the sa...

Cycle of maximum weight in a graph

Given a weighted graph (directed or undirected) I need to find the cycle of the graph with the maximum weight. The weight of a cycle being the sum of the weight of the edges of the graph. It can be any cycle, not just base cycle for which we can find all base cycle (see http://stackoverflow.com/questions/1607124/algorithms-to-identif...

Algorithm for determining if 2 graphs are isomorphic

Disclaimer: I'm a total newbie at graph theory and I'm not sure if this belongs on SO, Math SE, etc. Given 2 adjacency matrices A and B, how can I determine if A and B are isomorphic. For example, A and B which are not isomorphic and C and D which are isomorphic. A = [ 0 1 0 0 1 1 B = [ 0 1 1 0 0 0 1 0 1 0 0 1 1 0 ...

Creating a graph with edges of different colours in Mathematica

I want to create a graph (Graph Theory) where certain edges have a different colour to other edges, which would be used to highlight a path in the graph from one vertex to another. Here are some examples which have different coloured edges http://demonstrations.wolfram.com/AGraphTheoryInterpretationOfTheSumOfTheFirstNIntegers/ and http...

algorithm to enumerate all possible paths

Consider the following graph: I'm trying to find a way to enumerate all possible paths from a source node to a target node. For example, from A to E, we have the following possible paths: A B C D E A B C E A C D E A C E Note that for A C D E, there are actually 2 paths, since one of the paths uses edge F3 and the other uses edge F5...

CouchDB - Has anyone implemented a path/graph finding algorithm? Is it possible?

Has anyone implemented a path finding algorithm (A*, Dijkstra's algoritm, Breath First Search, etc.) using CouchDB's maps & views? Is it even possible? I've seen some implementations for other mapreduce software (e.g. http://horicky.blogspot.com/2010/02/nosql-graphdb.html), however they rely on an global state, which CouchDB lacks (right...

minimum connected subgraph containing a given set of nodes

I have an unweighted, connected graph. I want to find a connected subgraph that definitely includes a certain set of nodes, and as few extras as possible. How could this be accomplished? Just in case, I'll restate the question using more precise language. Let G(V,E) be an unweighted, undirected, connected graph. Let N be some subset...

Algorithm for counting connected components of a graph in Python

Hi, I try to write a script that counts connected components of a graph and I can't get the right solution. I have a simple graph with 6 nodes (vertexes), nodes 1 and 2 are connected, and nodes 3 and 4 are connected (6 vertexes; 1-2,3-4,5,6). So the graph contains 4 connected components. I use following script to count connected componen...

Finding Center of The Tree

I have a question which is part of my program. For a tree T=(V,E) we need to find the node v in the tree that minimize the length of the longest path from v to any other node. so how we find the center of the tree? Is there can be only one center or more? If anyone can give me good algorithm for this so i can get the idea on how i ca...

Find all chordless cycles in an undirected graph

How to find all chordless cycles in an undirected graph? For example, given the graph 0 --- 1 | | \ | | \ 4 --- 3 - 2 the algorithm should return 1-2-3 and 0-1-3-4, but never 0-1-2-3-4. (Note: [1] This question is not the same as small cycle finding in a planar graph because the graph is not necessarily planar. [2] I have...

Next Closest Pair Problem

I'm sure most are familiar with the closest pair problem, but is there another alogrithm or a way to modify the current CP algorithm to get the next closest pair? ...

Finding Eulerian Path In Perl

I have a code that try to find the Eulerian path like this. But somehow it doesn't work. What's wrong with the code? use strict; use warnings; use Data::Dumper; use Carp; my %graphs = ( 1 => [2,3], 2 => [1,3,4,5], 3 =>[1,2,4,5], 4 => [2,3,5], 5 => [2,3,4]); my @path = eulerPath(%graphs); sub eulerPath { my %graph = @_; # ...

Algorithm for splitting a connected graph into two components

Suppose I am given a weighted, connected graph. I'd like to find a list of edges that can be removed from the graph leaving it split into two components and so that the sum of the weights of the removed edges is small. Ideally I'd like to have the minimal sum, but I'd settle for a reasonable approximation. This seems like a hard problem...