graph-theory

Job scheduling with minimization by parallel grouping

半世苍凉 提交于 2020-07-07 16:11:30
问题 I have a job scheduling problem with a twist- a minimization constraint. The task is- I have many jobs, each with various dependencies on other jobs, without cycles. These jobs have categories as well, and can be ran together in parallel for free if they belong to the same category. So, I want to order the jobs so that each job comes after its dependencies, but arranged in such a way that they are grouped by category (to run many in parallel) to minimize the number of serial jobs I run. That

Job scheduling with minimization by parallel grouping

和自甴很熟 提交于 2020-07-07 16:11:27
问题 I have a job scheduling problem with a twist- a minimization constraint. The task is- I have many jobs, each with various dependencies on other jobs, without cycles. These jobs have categories as well, and can be ran together in parallel for free if they belong to the same category. So, I want to order the jobs so that each job comes after its dependencies, but arranged in such a way that they are grouped by category (to run many in parallel) to minimize the number of serial jobs I run. That

Job scheduling with minimization by parallel grouping

て烟熏妆下的殇ゞ 提交于 2020-07-07 16:11:11
问题 I have a job scheduling problem with a twist- a minimization constraint. The task is- I have many jobs, each with various dependencies on other jobs, without cycles. These jobs have categories as well, and can be ran together in parallel for free if they belong to the same category. So, I want to order the jobs so that each job comes after its dependencies, but arranged in such a way that they are grouped by category (to run many in parallel) to minimize the number of serial jobs I run. That

Prim's Algorithm Time Complexity

假装没事ソ 提交于 2020-07-03 02:17:05
问题 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 approach V^2, but when it does, the time complexity with a heap becomes O(V^2 lg(V)) which is greater than O(V^2). Obviously, a heap will improve performance over

Prim's Algorithm Time Complexity

99封情书 提交于 2020-07-03 02:14:37
问题 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 approach V^2, but when it does, the time complexity with a heap becomes O(V^2 lg(V)) which is greater than O(V^2). Obviously, a heap will improve performance over

How to create random graph where each node has at least 1 edge using Networkx

好久不见. 提交于 2020-06-28 03:58:11
问题 I've managed to create a random undirected weighted graph for testing with Dijkstra's algorithm, but how can I make it so each node has at least one edge that connects them to the graph? I'm using Networkx and my graph generator is as follows: import networkx as nx import random random.seed() nodes = random.randint(5,10) seed = random.randint(1,10) probability = random.random() G = nx.gnp_random_graph(nodes,probability,seed, False) for (u, v) in G.edges(): G.edges[u,v]['weight'] = random

Separate nested list into groups with disjoint elements

故事扮演 提交于 2020-06-27 13:07:05
问题 I have list of list that looks like this my_list = [[1, 2, 3, 4], [4, 5, 6, 7], [9, 10, 11, 12]] and I would like to find what's the best way to split the list into two groups so that the individual elements in each group are not overlapping. For instance, in the example above the two groups would be group1 = [[1, 2, 3, 4], [4, 5, 6, 7]] group2 = [[9, 10, 11, 12]] and this is because 9, 10, 11, 12 never appear in any of the items of group1 . 回答1: Similarly to Combine lists with common

Quadratic-time vertex cover verification

徘徊边缘 提交于 2020-06-18 01:32:23
问题 Suppose you are given an undirected graph G with n vertices and m edges represented by an n x n adjacency matrix A , and you are also given a subset of vertices S (represented by an array of size m ). How can you check whether S is a vertex cover of G with quadratic time and space complexity? By the definition of a vertex cover, I know that we require every edge must be incident to a vertex that's contained in S . I can easily come up with a cubic algorithm: iterate over the adjacency matrix;

Quadratic-time vertex cover verification

China☆狼群 提交于 2020-06-18 01:28:52
问题 Suppose you are given an undirected graph G with n vertices and m edges represented by an n x n adjacency matrix A , and you are also given a subset of vertices S (represented by an array of size m ). How can you check whether S is a vertex cover of G with quadratic time and space complexity? By the definition of a vertex cover, I know that we require every edge must be incident to a vertex that's contained in S . I can easily come up with a cubic algorithm: iterate over the adjacency matrix;

Combine (join) networkx Graphs

走远了吗. 提交于 2020-06-09 08:03:05
问题 Say I have two networkx graphs, G and H : G=nx.Graph() fromnodes=[0,1,1,1,1,1,2] tonodes=[1,2,3,4,5,6,7] for x,y in zip(fromnodes,tonodes): G.add_edge(x,y) H=nx.Graph() fromnodes=range(2,8) tonodes=range(8,14) for x,y in zip(fromnodes,tonodes): H.add_edge(x,y) What is the best way to join the two networkx graphs? I'd like to preserve the node names (note the common nodes, 2 to 7). When I used nx.disjoint_union(G,H) , this did not happen: >>> G.nodes() [0, 1, 2, 3, 4, 5, 6, 7] >>> H.nodes() [2