I would like to ask you about the following situation:
There is a class named A. It contains (aggregation) two classes (B and C), but they didn't inherited from the same base class.
Is it possible to associate B and C to A and use a constraint with {or}, but with only one reference at the A's side?
An other solution could be use of interface (Iface), so I can associate A with Iface, B and C can realise Iface.
But the question is that can I use constraint for this?
(as I found, associating B and C to A means that A will contain a reference for B and an other reference for C).
Thank you,
Ferenc
I think what you're asking is whether you can model A having a single association to another object, which can be of type B or C. Is that right?
In which case you don't need a constraint, just an association from A to a new class (call it "D") and then B and C would inherit from D, like this:
This does of course mean that you have to identify common characteristics of B and C to factor out into D to allow substitutability. And A can only rely on those features of B and C.
If you need A to have regular associations to B or C and can't use inheritance then you need separate associations with an {or} constraint as you've correctly identified.
Related
The image below shows a set that is supposed to describe a binary transitive relation:
That first arrow notation looks good at first until I saw the d node. I thought that since d cannot reach b (or any other node, yet it connects to c), it cannot be transitive?
A little bit of clarification would be great
The first panel is fine, i.e., it is transitive. Transtivity does not require d has a (directed) path to b in this case. Transitivity, by definition, requires "if there are x and y such that d → x and x → y, then it must be d → y". Since c (which potentially play the role of x here) does not go to anywhere, as for a chain of arrows that starts from d, there is no condition that needs to be satisfied (i.e., vacuously true, when starting from d).
A definition of subset that I found on the internet(In this web, 2nd point 3th paragraph) and in a book(set theory related topics by lipschutz, Page 3 - Def. 1-1) says or implies that:
A=B If at the same time A⊂B and B⊂A;
This would imply that A is contained in B, but it would also imply that B is contained in A.
Wouldn't this be a fallacy as demonstrated in Russell's paradox?
I imagine it would be something like that, it's this right?
This Img
Unfortunately, "contains" can be used in two very different ways for a set: "contains as a member" and "contains as a subset", so I would suggest avoiding it or being very clear which one you mean. I think the second one is less common to use "contains" for, but it still happens.
It's true that A can't be a member of B when B is a member of A (but not really related to Russell's paradox); but A can be a subset of B and B a subset of A. Just consider A={1} and B={1}. Then every member of A (i.e. 1) is a member of B, so A is a subset of B. And vice versa.
I imagine it would be something like that, it's this right? This Img
This would be if B is a proper subset of A (that is, a subset of A but not equal to A) and A is a proper subset of B.
A set X is contained in set Y if every element of X is in Y.
So, even if X is equal to Y, X is considered to be contained in Y.
At this point, it will be clear that if X is contained in Y and Y is contained in X as well in the same time, they should be equal.
I have a large network table that I want to simplify by merging nodes that share the same interactions, so that it will have a better network once imaged (I am using Cytoscape). The interactions do not have direction. As a mini example, if I have a table such as below.
A E
B E
C G
C H
D G
H D
E F
R S
The two columns are nodes that interact with each other. In this case since nodes A, B and F all only have connections to node E, I want to merge them so it's A,B,F as one node that interacts with E. Similarly since both C and D only interact with G and H I would want to merge them together. The resulting table should look something like below.
A,B,F E
C,D G
C,D H
R S
I have created a list with all the nodes, but I am not sure how to see if they have matching interactions since they can be in either column. Is there a good way/program to handle this?
For most networks, there would not be single solution to this problem. Once you start collapsing you begin to exclude other equally valid solutions. For example, even in your simplified example, these are other valid solutions:
A,B,F E
G,H C
G,H D
R S
or even
A,B,F E
C,D G,H
R S
And it gets more complicated once you include interactions across your relatively clean example, e.g., A G. But if your data really is partitioned like this example (which should be immediately apparent when you load it into iGraph or Cytoscape and perform any basic layout to see a bunch of separate networks), then you might be able to get a solution by querying all interaction partners for each node, then collapsing based on identical partner sets.
I don't know of a function iGraph or Cytoscape that can do this for you.
And if you network is not a partitioned set of multiple networks, then I don't think this is feasible at all.
Do I understand it right, that your cytoscape graph contains all said elements and the 'interactions' stand for edges in cytoscape? Because if your network has said elements and edges, you could, for example (this will not be a fast solution I think), make an array with all id' of your elements with
cy.nodes();
and then call
Object.keys(cy.edges("[target = '" + nodeId + "']")).length;
on every node in the array and save the number of edges going out of said node in the array. This way you can find all nodes with at least x nodes attached and then you can do whatever you want. You could e.g make the selected nodes to parents, so that the connected nodes are now inside the parent nodes?
Please tell me if this helps you or not :)
I'm working on a problem from the Languages and Machines: An Introduction to the Theory of Computer Science (3rd Edition) in Chapter 2 Example 6.
I need help finding the answer of:
Recursive definition of set strings over {a,b} that contains one b and even number of a's before the first b?
When looking for a recursive definition, start by identifying the base cases and then look for the recursive steps - like you're doing induction. What are the smallest strings in this language? Well, any string must have a b. Is b alone a string in the language? Why yes it is, since there are zero as that come before it and zero is an even number.
Rule 1: b is in L.
Now, given any string in the language, how can we get more strings? Well, we can apparently add any number of as to the end of the string and get another string in the language. In fact, we can get all such strings from b if we simply allow you to add one more a to the end of a string in the language. From x in L, we therefore recover xa, xaa, ..., xa^n, ... = xa*.
Rule 2: if x is in L then xa is in L.
Finally, what can we do to the beginning of strings in our language? The number of as must be even. So far, rules 1 and 2 only allow us to construct strings that have zero as before the b. We should be able to get two, four, six, etc., all the even numbers, of as. A rule that lets us add two as to any string in our language will let us add ever more as to the beginning while maintaining the evenness property we require. Starting with x in L, we recover aax, aaaax, ..., (aa)^(2n)x, ... = (aa)*x.
Rule 3: if x is in L, then aax is in L.
Optionally, you may add the sometimes implicitly understood rule that only those things allowed by the aforementioned rules are allowed. Otherwise, technically anything is allowed since we haven't explicitly disallowed anything yet.
Rule 4: Nothing is in L unless by virtue of some combination of the rules 1, 2 and/or 3 above.
I want to give an array index to array collection let say 205 when it is started is it possible to do so in flex or any alternate of this.
actually I need to index the objects with a specific no, in 2D array collection
say
205 a c d g f d
268 s g h g f f
805 d g h h f f d
where integers are indexes and alphabets are object referenced by these integers
ArrayCollections are wrappers for Arrays (with more functionality + binding + all sorts of awesome [if one can use awesome as a noun]).
The Array class is not as "associative" as is the Dictionary class. So, you could either use a dictionary, which is probably what you're really looking for. Or you could extend ArrayCollection (which extends ListCollectionView which extends Proxy -- which was #BrianBenisio's suggestion). So it really depends on your project, what you want to accomplish, if you need binding, and how much time you have.
You gave the example by detailing a 2D collection:
205 a c d g f d
268 s g h g f f
805 d g h h f f d
so I'm going to guess that you are dealing with a datasource that is xml based (or at least based on something similar to SimpleDB, with rows that don't have static columns). So if it were me, I'd stick with an Array and build an internal "ArrayUtils" class that acts as a means to your end. Though, if you're using the latest version of Flex, you may want to think about typing your array and going down the path of using the Vector class. With a customized typed vector, you'll find better performance and customizable functionality that you'd otherwise be missing.
Good luck in any case.
rock on,
Jeremy
I am having some trouble completely understanding your question, but if I do understand you correctly, you want to override the indexing method of an object?
The easiest way to do this is to have your class extend Proxy. You need to override nextNameIndex(index:int):int and nextValue(index:int):*. If that is a bit confusing, just put breakpoints in your overrides when you try to do something like myObject[205].
Good luck :)