Some improvements and additions to the SimpleGraph.pl macro.#1379
Some improvements and additions to the SimpleGraph.pl macro.#1379drgrice1 wants to merge 7 commits intoopenwebwork:developfrom
SimpleGraph.pl macro.#1379Conversation
d0eca9c to
da670d0
Compare
|
There is one more change that I just added. It is a bug fix. The |
|
Another change added. Improvements to the |
92eeadf to
c67600d
Compare
|
One more change added. Improvements to the |
ddbb4ee to
3976973
Compare
This color has a contrast ratio of 6.68 against the white background. The red color has a contrast ration of 4.00 which is not sufficient for accessibility purposes.
The method returns an array containing references to arrays that form a
partition the vertex indices into the connected components of the graph.
For example, for the graph with vertices E, F, G, H, I, J, K, and L, and
edge set {{{E, L}, {F, G}, {F, L}, {G, J}, {H, I}, {J, K}, {J, L}}}, the
method will return ([E, F, G, J, K, L], [H, I]).
Instead of trying to place the labels using the coordinates, use the `anchor` and padding options to get better positioning. The primary advantage is now the labels don't float away when the image is enlarged. This was not done originally because at the time this macro was implemented the `anchor` and `padding` options didn't exist. The weights for the default layout and the wheel layout are still positioned along the perpendicular vector for now. The problem is that those labels are rotated, and that does not work well with the anchor. This is a TikZ issue (I implemented the anchor for JSXGraph to work the same as the TikZ anchor option). The problem is that the rotation is around the position of the anchor, and not around the center of the text. The usual solution for this in TikZ is to use a `\rotatebox` on the node contents. Perhaps another rotation option could be addded to the plots macro that would rotate the text instead of rotating around the anchor position.
an invalid edge set for a graph with a single edge.
First, the method is now quite a bit more efficient. Rather than finding and sorting only the weights of the edges in the graph, and then searching through the graph to find those edges at each step in the algorithm, the edges with the weights are all listed and sorted by weight (more like the actual sorted edges algorithm works). So there is no need to find the edge later, you just follow the algorithm and process the edges in order. Second, the return value of the method is reordered and more data returned. See the updated POD for good documentation on what is returned. This makes the method return a lot more useful information that can be used for constructing a solution to problems using the sorted edges algorithm.
First, the method is now quite a bit more efficient. Rather than finding and sorting only the weights of the edges in the graph, and then searching through the graph to find those edges at each step in the algorithm, the edges with the weights are all listed and sorted by weight (more like the actual sorted edges algorithm works). So there is no need to find the edge later, you just follow the algorithm and process the edges in order. Also make the algorithm terminate once the minimal spanning tree is complete as it should. Second, the return value of the method returns more data. See the updated POD for good documentation on what is returned. This makes the method return more useful information that can be used for constructing a solution to problems using the sorted edges algorithm. These is the basically the same changes that were made for the `sortedEdgesPath` method.
3976973 to
8c0898d
Compare
This returns a translated string description of the graph. The string that is returned is suitable for use as the "alt" text for the image returned by one of the image methods.
571f10b to
e170228
Compare
|
One more addition. I added a Translation of general lists is rather challenging, but I think the way it is done should work for most languages. |
First, change the weight color used from red to FireBrick. This color has a contrast ratio of 6.68 against the white background. The red color has a contrast ration of 4.00 which is not sufficient for accessibility purposes.
Second, improve label positioning. Instead of trying to place the labels using the coordinates, use the
anchorand padding options to get better positioning. The primary advantage is now the labels don't float away when the image is enlarged. This was not done originally because at the time this macro was implemented theanchorandpaddingoptions didn't exist.The weights for the default layout and the wheel layout are still positioned along the perpendicular vector for now. The problem is that those labels are rotated, and that does not work well with the anchor. This is a TikZ issue (I implemented the anchor for JSXGraph to work the same as the TikZ anchor option). The problem is that the rotation is around the position of the anchor, and not around the center of the text. The usual solution for this in TikZ is to use a
\rotateboxon the node contents. Perhaps another rotation option could be addded to the plots macro that would rotate the text instead of rotating around the anchor position.Third, add a
componentsmethod that returns the components of the graph. The method returns an array containing references to arrays that form a partition the vertex indices into the connected components of the graph. For example, for the graph with vertices E, F, G, H, I, J, K, and L, and edge set {{{E, L}, {F, G}, {F, L}, {G, J}, {H, I}, {J, K}, {J, L}}}, the method will return ([E, F, G, J, K, L], [H, I]).