No of Minimum spanning trees should be 2 but solution says 1 - minimum-spanning-tree

I am trying to solve a problem on weight of MST and no of such MSTs.
In this probem, the weight of MST found by PRIM'S algorithm is 34, but there can be 2 MSTs possible; one tree with edge BC and the other with edge EF. But given answer is only 1.
Am i going wrong anywhere ?

Related

Non Scaled SSRS Line Chart with mulitple series

I am trying to present time series of multiple sensors on a single SSRS (v14) line chart
I need to plot N series, with each independently plotting the series data in the space provided by the chart (independent vertical axis)
More about the data
There can be anywhere from ~1-10 series
The challenge is that they are different orders of magnitude.
One might be degrees F (~0-212)
One might be Carbon ppm (~1-16)
One might be Ftlbs Thrust (~10k-100k)
the point is , they have no relation and can be very different
The exact value is not important. I can hide the vertical axis
More about what I am trying to do
The idea is to show the multiple time series, plotted together against time for the 4 hours before and after
'an event'. Its not the necessarily the exact value that is important. the subject matter expert would be looking for something odd (temperature falls, thrust spikes, etc).
Things I have tried
If there were just 2 series, i could easily use the 2nd axis available in the SSRS chart. Thats exactly the idea I am chasing. But in this case, I want N series to plot using its own axis.
I have tried stacking N transparent graphs on top of each other. This would be a really ugly solution, but SSRS even wont let you do it. It unstacks them for you.
I have experimented with the Allow Scale Breaks property on the Vert Axis. This would solve the problem but we don't like the 'double jagged line'
Turning on Logarithmic scale is a possibility. It does do a better job of displaying all the data. but its not really what we want. Its going to change the shape of data that ranges over a couple orders of magnitude.
I tried the sparkline component and am having the same problem.
This approach is essentially the same a Greg's answer above. I've had to do this same process in the past comparing trends of data even though the units were dissimilar.
I took a very simple approach of adding an additional column to the query that showed each value as a percentage of the maximum value in each series.
As an example (just 2 series here for clarity) I started with data like this in myTable
Series Month myValue
A Jan 4
A Feb 8
A Mar 16
B Jan 200
B Feb 300
B Mar 400
My Dataset query would be something like.
SELECT *, myValue / MAX(myValue) OVER(PARTITION BY Series) as myPlotValue FROM myTable
This gives us a final dataset which looks liek this.
Series Month myValue myPlotValue
A Jan 4 0.25
A Feb 8 0.5
A Mar 16 1
B Jan 200 0.5
B Feb 300 0.75
B Mar 400 1
As you can see all plot values are now between 0 and 1.
I created that charts using the myPlotValue field and had the option of using the original values from the myValue field as datapoint labels.
After talking to some math people, this is a standard problem and it is solved by a process called normalization of the data.
Essentially you are changing all the series to fit in a given range (usually 0-1)
You can scale and add an offset if that makes sense for your problem domain somehow.
https://www.statisticshowto.datasciencecentral.com/normalized/

Given an MST for an edge-weighted graph, how can you find the minimally weighted path from x to y?

I have an edge-weighted undirected graph represented by a minimum spanning tree. Each vertice is represented by an integer. The MST looks like this:
I wonder, how can I use this MST to find the shortest path from a vertex x to a vertex y? Say I want to find the shortest path from 0 to 3. It's easy to see that the path is 0-2, 2-3 with total weight 0.26+0.17 = 0.43. But how should I construct a general way of doing this? in pseudocode
edge weight
6-2 0,40
4-5 0.35
5-7 0.28
2-3 0.17
0-2 0.26
1-7 0.19
0-7 0.16
In this case, since you are given an MST you only know that the total edge weights in the graph are minimal. However, a path between two nodes in an MST does not guarantee that it is the minimal path between those two nodes on the actual graph. In order to find the minimally weighted path from node x to node y, you can perform Dijkstra's Algorithm on the original graph (not the MST). Dijkstra's can find the minimum distance from a starting node, in this case, x, to every other node in the graph.
Perform Dijkstra's Algorithm as follows and store the information in a table:
Begin at the starting node, x in this case and go to the node with the least weight from x
From the lowest weight node just visited, explore the neighbors and again pick the edge with the lowest weight
Sum up the total cost so far from the edge you are visiting. If you started at x, then visited a, then c, find the total distance from x to a to c.
If the weight to a node is lower than what was previously recorded, update the value in the table because now a shorter path has been found.
Ultimately, after performing this algorithm, the table should contain the lowest weight path from x to y.
The MST does not necessarily contain the shortest path from one vertex x to another vector y. The minimum spanning tree is a tree that has found the minimal path for every node to be visited. This does not necessarily mean that the shortest path from x to y is included in the MST. To find the true shortest path from x to y you would have to run an algorithm to find the shortest path on the original graph, like Dijkstra's.

Importing Nodes with Coordinates to Gephi from CSV

This question seems pretty stupid but I actually fail to find a simple solution to this. I have a csv file that is structured like this:
0 21 34.00 34.00
1 23 35.00 25.00
2 25 45.00 65.00
The first column is the node's id, the second is an unimportant attribute. The 3rd and 4th attribute are supposed to be the x and y position of the nodes.
I can import the file into the Data Laboratory without problems, but I fail to explain to Gephi to use the x y attributes as the corresponding properties. All I want to achieve is that Gephi sets the x Property to the value of the x Attribute (and y respectively). Also see picture.
Thanks for your help!
In the Layout window, you can select "Geo Layout" and define which columns are used as Latitude and Longitude.
The projection might come in weird if you do not actually have GeoData, but for me, this is fine.
In Gephi 0.8 there was a plugin called Recast column. This plugin is unfortunately not ported to Gephi 0.9 yet, but it allowed you to set Standard (hidden) Columns in the Node Table, from visible values in the nodes table. Thus if you have two columns of type Float or Decimal that represent your coordinates, you could set the coordinate values of your nodes.

Bliss bug? Automorphism group generators depend on branching heuristic

I'm trying to use Bliss to compute the automorphism group generators of a graph. I thought I'd rather ask here on SO before I bother the auther with "bug", which is actually just my fault.
One of the options of bliss is the branching heuristic, which specifies which cell (of a partition of the vertices) is considered next.
e.g.
f means First non-unit cell.
fs means First smallest non-unit cell.
fsm means First smallest maximally non-trivially connected non-unit cell.
etc.
This graph gives me a headache: http://pastebin.com/Ppq7N1mN (file format: http://www.tcs.hut.fi/Software/bliss/fileformat.shtml)
Surprisingly, the numbers of generators differ for different branching heuristics... The modes f, fl return 2 generators, but I think there are 3, which fs,fm,fsm and flm confirm.
It's weird that the automorphism group size matches |Aut|=8. I checked why, and somehow bliss thinks that the orbit of one of the generators has size 4 and thus calculates the order 2*4=8. I don't exactly know how the algorithm works nor do I understand the code well enough so that I could find a bug.
So my question is: Am I missing something and this behaviour is normal or is that a bug in the library?
And here's the output. That the canonical labellings are different is expected!
bliss -directed -can -sh=f test.dimacs
Generator: (2,4)(10,18)(11,20)(12,19)(13,21)(40,76)(41,77)(42,78)(43,79)(44,80)(45,81)(46,82)(47,83)(48,84)(49,85)(50,86)(51,87)(52,88)(53,89)(54,90)(55,91)(56,92)(57,93)
Generator: (1,2)(3,4)(6,10)(7,11)(8,13)(9,12)(14,18)(15,20)(16,21)(17,19)(22,43)(23,42)(24,41)(25,40)(26,57)(27,56)(28,55)(29,54)(30,53)(31,52)(32,51)(33,50)(34,49)(35,48)(36,47)(37,46)(38,45)(39,44)(58,79)(59,78)(60,77)(61,76)(62,93)(63,92)(64,91)(65,90)(66,89)(67,88)(68,87)(69,86)(70,85)(71,84)(72,83)(73,82)(74,81)(75,80)(94,95)
Canonical labeling: (1,4)(6,20,14,21)(7,16,8,9,12,11,15,17,13)(10,19)(22,77,66,24,68,30,25,73,88,90,39,44,43,75,45,29,41,67,92,54,40,71,51,32,33,49,83,34,85,82,86,46,87,31,93,64,80,42,61,72,37,89)(23,58,76,70,84,52,91,78,60,69,48,53)(26,62,63,57,65,38)(27,56,55,79,74)(28,81)(35,50,47)
Nodes: 6
Leaf nodes: 4
Bad nodes: 0
Canrep updates: 1
Generators: 2
Max level: 2
|Aut|: 8
Total time: 0.06 seconds
bliss -directed -can -sh=fsm test.dimacs
Generator: (2,4)(10,18)(11,20)(12,19)(13,21)(40,76)(41,77)(42,78)(43,79)(44,80)(45,81)(46,82)(47,83)(48,84)(49,85)(50,86)(51,87)(52,88)(53,89)(54,90)(55,91)(56,92)(57,93)
Generator: (1,3)(6,14)(7,15)(8,16)(9,17)(22,58)(23,59)(24,60)(25,61)(26,62)(27,63)(28,64)(29,65)(30,66)(31,67)(32,68)(33,69)(34,70)(35,71)(36,72)(37,73)(38,74)(39,75)
Generator: (1,2)(3,4)(6,10)(7,11)(8,13)(9,12)(14,18)(15,20)(16,21)(17,19)(22,43)(23,42)(24,41)(25,40)(26,57)(27,56)(28,55)(29,54)(30,53)(31,52)(32,51)(33,50)(34,49)(35,48)(36,47)(37,46)(38,45)(39,44)(58,79)(59,78)(60,77)(61,76)(62,93)(63,92)(64,91)(65,90)(66,89)(67,88)(68,87)(69,86)(70,85)(71,84)(72,83)(73,82)(74,81)(75,80)(94,95)
Canonical labeling: (1,2,4,3)(6,21,8,7,15,14,20,16)(9,13)(10,19)(11,17,12)(22,75,42,59,60,66)(23,61,72,34,83,36,35,53,25,73,86,48,51,31,93,62,64,80,44,45,27,55,79,76,70,82,88,90,38,29,41,69,46,89,24,67,92,56,57,63,54,39,43,77,68,32,33,47,37,87,30)(26,65,40,71,52,91,78,58,74,28,81)(49,85,84,50)(94,95)
Nodes: 9
Leaf nodes: 4
Bad nodes: 0
Canrep updates: 1
Generators: 3
Max level: 3
|Aut|: 8
Total time: 0.06 seconds
I didn't know how to tag this question, so I chose igraph - a library that uses bliss for this problem.
A friend of mine suggested that the generating set of the second method might not be minimal. And indeed you can get the missing generator from the other two:
(1 2)(3 4)... * (2 4)(10 18)... * (1 2)(3 4)... = (1 3)(6 14)...

How many combinations of k neighboring pixels are there in an image?

I suck at math, so I can't figure this out: how many combinations of k neighboring pixels are there in an image? Combinations of k pixels out of n * n total pixels in the image, but with the restriction that they must be neighbors, for each k from 2 to n * n. I need the sum for all values of k for a program that must take into account that many elements in a set that it's reasoning about.
Neighbors are 4-connected and do not wrap-around.
Once you get the number of distinct shapes for a blob of pixels of size k (here's a reference) then it comes down to two things:
How many ways on your image can you place this blob?
How many of these are the same so that you don't double-count (because of symmetries)?
Getting an exact answer is a huge computational job (you're looking at more than 10^30 distinct shapes for k=56 -- imagine if k = 10,000) but you may be able to get good enough for what you need by fitting for the first 50 values of k.
(Note: the reference in the wikipedia article takes care of duplicates with their definition of A_k.)
It seems that you are working on a problem that can be mapped to Markovian Walks.
If I understand your question, you are trying to count paths of length k like this:
Start (end)-> any pixel after visiting k neighbours
* - - - - -*
| |
| |
- - - -
in a structure that is similar to a chess board, and you want to connect only vertical and horizontal neighbours.
I think that you want the paths to be self avoiding, meaning that a pixel should not be traversed twice in a walk (meaning no loops). This condition lead to a classical problem called SAWs (Self Avoiding Walks).
Well, now the bad news: The problem is open! No one solved it yet.
You can find a nice intro to the problem here, starting at page 54 (or page 16, the counting is confusing because the page numbers are repeating in the doc). But the whole paper is very interesting and easy to read. It manages to explain the mathematical background, the historical anecdotes and the scientific importance of markovian chains in a few slides.
Hope this helps ... to avoid the problem.
If you were planning to iterate over all possible polyominos, I'm afraid you'll be waiting a long time. From the wikipedia site about polyominos, it's going to be at least O(4.0626^n) and probably closer to O(8^n). By the time n=14, the count will be over 5 billion and too big to fit into an int. By time n=30, the count will be more than 17 quintillion and you won't be able to fit it into a long. If all the world governments pooled together their resources to iterate through all polyominos in a 32 x 32 icon, they would not be able to do it before the sun goes supernova.
Now that doesn't mean what you want to do is intractable. It is likely almost all the work you do on one polyominal was done in part on others. It may be a fun task make an exponential speedup using dynamic programming. What is it you're trying to accomplish?