graph-theory

Building or Finding a “relevant terms” suggestion feature

元气小坏坏 提交于 2019-12-03 05:19:26
问题 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", "steroids", ... ] Google Sets is the best example I can find of this kind of feature, but I can't use it since they have no public API (and I wont go against

How to find two disjoint spanning trees of an undirected graph

僤鯓⒐⒋嵵緔 提交于 2019-12-03 03:33:24
Is there any applicable approach to find two disjoint spanning trees of an undirected graph or to check if a certain graph has two disjoint spanning trees This is an example of Matroid union. Consider the graphic matroid where the basis are given by the spanning trees. Now the union of this matroid with itself is again a matroid. Your question is about the size of the basis of this matroid. (whether there exist a basis of size $2(|V|-1)$. The canonical algorithm for this is Matroid partitioning algorithm. There exist an algorithm which does does the following: It maintains a set of edges with

What is meant by diameter of a network?

≡放荡痞女 提交于 2019-12-03 03:15:50
问题 The diagram shown on this link of the " A graph with 6 vertices and 7 edges where the vertex no 6 on the far-left is a leaf vertex or a pendant vertex. " has DIAMETER 4? right or wrong? Definitions are The diameter of a graph is the maximum eccentricity of any vertex in the graph. That is, it is the greatest distance between any pair of vertices. To find the diameter of a graph, first find the shortest path between each pair of vertices. The greatest length of any of these paths is the

Don't understand closest pair heuristic from “The Algorithm Design Manual ”

老子叫甜甜 提交于 2019-12-03 03:15:22
There is almost exactly the same question . But I still don't understand, how is this heuristic working and in what sequence vertexes are passed through. Also there is a picture in a book: That shows comparison of nearest-neghbor heuristic and what I believe is a closest-pair heuristic. From the picture I may assume that on the top picture, 0 point was selected first, but on the bottom picture there was selected the leftmost or the rightmost one. Because there is nothing said about first point selection (also the closest-pair heuristic doesn't do any actions in that), I may assume that any

Calculate Family Relationship from Genealogical Data

你说的曾经没有我的故事 提交于 2019-12-03 03:14:15
问题 I would like to be able to calculate the family relationship between two individuals in a family tree, given the following data schema (simplified from my actual data schema, only showing columns that directly apply to this problem): individual ---------- id gender child ---------- child_id father_id mother_id With this structure, how can one calculate the relationship between two individual id's (i.e. cousin, great grand uncle, etc.). Also, as there are actually two relationships (i.e. A-B

Implementing a randomly generated maze using Prim's Algorithm

余生颓废 提交于 2019-12-03 02:52:51
I am trying to implement a randomly generated maze using Prim's algorithm. I want my maze to look like this: however the mazes that I am generating from my program look like this: I'm currently stuck on correctly implementing the steps highlighted in bold: Start with a grid full of walls. Pick a cell, mark it as part of the maze. Add the walls of the cell to the wall list. While there are walls in the list: **1. Pick a random wall from the list. If the cell on the opposite side isn't in the maze yet: Make the wall a passage and mark the cell on the opposite side as part of the maze.** Add the

Names of Graph Traversal Algorithms

狂风中的少年 提交于 2019-12-03 02:49:43
问题 What I'm looking for is a comprehensive list of graph traversal algorithms, with brief descriptions of their purpose, as a jump off point for researching them. So far I'm aware of: Dijkstra's - single-source shortest path Kruskal's - finds a minimum spanning tree What are some other well-known ones? Please provide a brief description of each algorithm to each of your answers. 回答1: the well knowns are : Depth-first search http://en.wikipedia.org/wiki/Depth-first_search Breadth-first search

Multigraphs with javascript

假如想象 提交于 2019-12-03 02:48:47
问题 First of all look at this question. None of those libraries support Multigraphs (or Pseudographs ). I mean I can't generate graphs like this: Is there any jQuery plugin (or javascript library) out there for this purpose ? I thought i can use WolframAlpha's API and use its images, something like this: but it have lots of problem: I can't move nodes or add remove edges interactively. Only 2000 API calls per month. Not enough. I can't produce large or intermediate graphs. Its really ugly !

Algorithm for merging sets that share at least 2 elements

守給你的承諾、 提交于 2019-12-03 02:22:39
Given a list of sets: S_1 : [ 1, 2, 3, 4 ] S_2 : [ 3, 4, 5, 6, 7 ] S_3 : [ 8, 9, 10, 11 ] S_4 : [ 1, 8, 12, 13 ] S_5 : [ 6, 7, 14, 15, 16, 17 ] What the most efficient way to merge all sets that share at least 2 elements? I suppose this is similar to a connected components problem. So the result would be: [ 1, 2, 3, 4, 5, 6, 7, 14, 15, 16, 17] (S_1 UNION S_2 UNION S_5) [ 8, 9, 10, 11 ] [ 1, 8, 12, 13 ] (S_4 shares 1 with S_1, and 8 with S_3, but not merged because they only share one element in each) The naive implementation is O(N^2), where N is the number of sets, which is unworkable for us.

how to find Connected Component dynamically

眉间皱痕 提交于 2019-12-03 01:59:26
Using disjoint-set data structure can easily get connected component of Graph. And, it just supports Incremental Connected Components . However, in my case, removing edge is very common so that I am looking for an algorithm or new structure can maintain Connected Components fully dynamically (including adding and removing edge) Thanks Poly-logarithmic deterministic fully-dynamic algorithms for connectivity, minimum spanning tree, 2-edge, and biconnectivity (Holm, de Lichtenberg and Thorup 2001) gives an algorithm that allows an arbitrary sequence of edge insertions, deletions and connectivity