graph-theory

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

偶尔善良 提交于 2019-12-09 09:30:13
问题 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 appreciate if someone with a more solid background could review my reasoning. Say I represent a DAG of n vertices in an n * n adjacency matrix such that the

Large scale graph visualization (50K nodes, 100M weighted edges)

北城余情 提交于 2019-12-09 09:25:46
问题 I've looked at a number of packages for graph layout (Graphviz, Gephi, Cytoscape, NetworkX to name a few of the more prevalent) and none of them seem to scale to this sort of size. What techniques exist for either visualizing graphs of this size or reducing them to something more manageable? 回答1: Gephi's OpenOrd visualisation plugin can layout millions of nodes. 回答2: I've used the visualisation toolkit Processing for visualising networks of about 30K nodes. It won't have any problems

Generate a DAG from a poset using stricly functional programming

南笙酒味 提交于 2019-12-09 08:33:50
问题 Here is my problem: I have a sequence S of (nonempty but possibly not distinct) sets s_i, and for each s_i need to know how many sets s_j in S (i ≠ j) are subsets of s_i. I also need incremental performance: once I have all my counts, I may replace one set s_i by some subset of s_i and update the counts incrementally. Performing all this using purely functional code would be a huge plus (I code in Scala). As set inclusion is a partial ordering, I thought the best way to solve my problem would

Coordinate compression

烈酒焚心 提交于 2019-12-09 06:22:24
问题 Problem: You have an N x N grid (1 <= N <= 10^9). Each square can either be traversed or is blocked. There are M (1 <= M <= 100) obstacles in the grid, each one shaped like a 1xK or Kx1 strip of grid squares. Each obstacle is specified by two endpoints (A_i, B_i) and (C_i, D_i), where A_i=C_i or B_i=D_i. You are also given a start square (X,Y). The question is: how many squares are reachable from the start square if you can go left, right, up, and down, and you cannot traverse obstacles? I

What options are available for the layout of directed or undirected graphs in .NET?

只愿长相守 提交于 2019-12-09 04:15:25
问题 By graph here I mean something resembling these images: The ideal solution would: use only managed code allow output to a bitmap image allow output to WPF elements include some kind of interactive surface for displaying the graph that supports zooming, panning and reorganisation of nodes I'm also interested in hearing about projects that could potentially be used as the starting point for this kind of work. If it requires some development to achieve what I want, then I'm prepared to tackle it

Use Dijkstra's to find a Minimum Spanning Tree?

牧云@^-^@ 提交于 2019-12-09 02:36:35
问题 Dijkstra's is typically used to find the shortest distance between two nodes in a graph. Can it be used to find a minimum spanning tree? If so, how? Edit: This isn't homework, but I am trying to understand a question on an old practice exam. 回答1: Strictly, the answer is no. Dijkstra's algorithm finds the shortest path between 2 vertices on a graph. However, a very small change to the algorithm produces another algorithm which does efficiently produce an MST. The Algorithm Design Manual is the

Number of complete graph components

只愿长相守 提交于 2019-12-08 11:48:23
问题 Given an undirected graph. How do I check if it can be divided into two sets where every node of one set is connected to every other node of its own set (complete graph). A set can be empty or of only one node. No node should be remaining. Thanks. EDIT: Edges between two sets is not forbidden. Basically we have to check if the graph can be divided into two cliques 回答1: As commented by @Damien, checking whether vertices of a given graph can be partitioned into two cliques is actually the

Writing a DFS with iterative deepening without recursion

狂风中的少年 提交于 2019-12-08 10:28:34
问题 So currently i have a DFS with the following pseudocode procedure DFS(Graph,source): create a stack S push source onto S mark source while S is not empty: pop an item from S into v for each edge e incident on v in Graph: let w be the other end of e if w is not marked: mark w push w onto S How do I alter this function to accept a third argument that limits the depth of the search? 回答1: Let Node a structure for each node of the graph, add a field called level and then: procedure DFS(Graph

Finding “strongly connected” subgraphs in a Graph

半城伤御伤魂 提交于 2019-12-08 09:47:45
问题 I am trying to find an algorithm to find the sub graphs in a undirected connected graph, where each vertex in the subgraph has an edge to every other vertex in the subgraph. My real problem is that I am having trouble classifying this problem, so that I can research possible algorithms or solutions. Would anyone know what this problem is called or is there any existing algorithms that achieve this? 回答1: I believe that you are referring to the Clique problem. 回答2: Hmm, I believe I encountered

Why is the Inverse Ackermann function used to describe complexity of Kruskal's algorithm?

妖精的绣舞 提交于 2019-12-08 08:57:01
问题 In a class for analysis of algorithms, we are presented with this pseudocode for Kruskal's algorithm: He then states the following, for disjoint-set forests: A sequence of m MAKE-SET, UNION, and FIND-SET operations, n of which are MAKE-SET operations, can be performed on a disjoint-set forest with union by rank and path compression in worst-case time O(m α(n)) . Used to compute the complexity of Step 2, and steps 5-8 For connected G: |E| ≥ |V| -1; m = O(V + E), n = O(V); So Steps 2, 5-8: O((V