spnsp

1

votes
0

answer
44

views

Iterate vector of pairs

I have vector1 [1,2,5,4,7]. I have another vector2 [(1,1),(2,5),(3,6),(4,7)]. I want to check if the element in Vector1 is the first or second element in the pair vector2. this is the code snippet. Any better approach other than this which takes less time ? std::vector vector1; std::vector vector2;...
spnsp
1

votes
1

answer
127

views

Which boost library should i use to add the intervals as mentioned in the description?

I am working on intervals in a c++ program. I want something like below: I want to add intervals iteratively in a for loop. Assume my first interval is (0, 5). I want to add an interval (3,6) such that the resulting interval set should be (0,3), (3,6). If my third interval added is (4,7), my resulti...
spnsp
1

votes
1

answer
112

views

Adding vertex in graph using boost as the elements of a vector

I have a vector say [3,2,1,8,7]. The vertices of the Graph should be 3,2,1,8,7. How can i create this in a loop. Can i use add_vertex function of boost in a loop which iterates through this vector ? Or which is the best way to add these vector elements as the vertices of the graph ? This is what i h...
spnsp
3

votes
2

answer
86

views

Random number generation from a vector of numbers

I have a vector v = {1,5,4,2}. Now I want to write a function that returns a random pair of numbers from this vector. Example: {1,2},{4,4},{2,5},{5,1},{1,5},{2,2}....... I want this pair to be generated in a random manner. Any idea how to implement this ?
spnsp
1

votes
1

answer
317

views

Directed Acyclic Graph : Updating the vertex property of a parent node by comparing the property of the child nodes.

I have the connections between nodes in a DAG like this. 1 --> 7 2 --> 3 --> 4 5 4 --> 6 5 --> 6 --> 7 --> I have to perform some tasks on this graph. 1) Find all the vertices without successors. 2) Assign a value to the vertices without successors. (I can do this with Vertex properties). 3) Back...
spnsp
2

votes
1

answer
40

views

Python 4D plot using matplotlib- confusion in reading and plotting the array

I have a list like below - array1 = [[1,2,3,0.56],[12,5,30,0.23],[10,12,17,89.65]] This represents co-ordinates- [[x1,y1,z1,c1],[x2,y2,z2,c2],[x3,y3,z3,c3]]. I used 4D plot with 4th dimension[c1,c2,c3] being the color. I am stuck at plotting. I would like to have a color for c1 at co-ordinates [x1,y...
spnsp