cytoscape.js successors and predecessors - cytoscape.js

I'm looking to select the successors and the predecessors from a selected node within my graph. Essentially what I need my code to do is select the full path in and out of a note right to the end nodes.
I know how to select one or the other (successors or predecessors) but not both,
i'm currently using :
var nhood = node.successors();
cy.batch(function(){
cy.elements().not( nhood ).removeClass('highlighted').addClass('faded');
nhood.removeClass('faded').addClass('highlighted');
I'm very new to JS and I'm pretty much fumbling around in the dark just now, learning as I go, so please excuse me if this is a simple question.
Thanks.

You look like you want a BFS instead, because you want the entire connected component essentially. See http://js.cytoscape.org/#collection/algorithms/eles.breadthFirstSearch
You can keep an array and put visited nodes into them.

Related

How to spawn objects (boxes) with a certain logic in Unreal Engine 4 WITHOUT blueprints?

I am new to ue4, so the question may be easy or have a tutorial that I couldn't find:)
I have a world in ue4 (imported) which is static. I want to add some boxes (with different pictures on each) which will spawn/despawn from the world at certain times and locations. How would I do that in a project without blueprints? A link to a tutorial or an explanation would be very much appreciated.
In addition, I would like some of the boxes to move in a simple "patrol". In this too, any help would be appreciated
To spawn an actor, just call SpawnActor method
auto myActor = GetWorld()->SpawnActor<MyActorType>(MyActorType::StaticClass(), location, rotation, spawnParameters);
It returns a pointer to the spawned entity: if you want to update it, just keep it and then at every tick set a new position/orientation
myActor->SetActorLocationAndRotation(
newPosition,
newOrientation,
false,
nullptr,
ETeleportType::None
);

Algolia vue-instantsearch : disjunction between two distincts facets

Using algolia vue-instantsearch, i’m encountering a special case and i’m having an hard time finding a solution.
Refinement behaviors is that you get the results that matches all your refinement filters.
If i filter on a brand and a price, i’ll get the results that matches both the brand and the price.
I need to add some specific filters that work differently. I would like to be able to say “returns me the results that matches either refinementA, or refinementB, or refinementC.”
The reason is that those refinements are checking fields that are not present on all the products.
If i check a value for refinementA, i want to keep all the results that has no value for field corresponding to refinementA, but remove those that has a value for refinementA that does not match with the one i filtered one.
Im thinking about handling myself some inputs instead of ias-components, and modifying by hand each query that is send to algolia by checking the value of my own inputs when searchFunction is triggered (https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/#widget-param-searchfunction).
I did not found yet how i can trigger a search from an non-vue-instantsearch input event, and i’m not sure how the above solution could affect the internal working of vue-instantsearch.
I’m looking for feedbacks about a more standard way of doing this, or for any advices !
I got the answer by exchanging with a vue-instantsearch maintainer.
vue-instantsearch does not provide any option to do it.
A workaround is to overwrite algoliasearch search method, that is used under the hood by vue-instant-search.
const client = algoliasearch('', '');
const originalSearch = client.search;
client.search = function search(queries) { ... }
More informations in this github issue : https://github.com/algolia/vue-instantsearch/issues/1102

Is there any example or sample code for the find and filter feature in Cytoscape JS

I saw in cytoscape application we have features like find and filter by keywords and degree. I tried a workaround following the original docs. Here you can see the demo webdemo.intolap.com/cytoscape (view-source for the source code or snippet). The filter works well partially. Example, "apple" will display apple and it's connected nodes (1st level) just what I am looking for.
But the problem I am facing is about resetting the graph and filter again with a
different keyword. It seems the filter function does not work after the text box is cleared and then keyed in a different keyword.
I mean when I clear the text box, it resets the graph to original which is correct. I did that using an init() function which reinstates the graph. But then if I search for "Ball" filter does not work. Any help please. Thanks!
actually there is a reasonably good explanation in the official docs here, but to be honest, I too struggled with this feature at first:
Basically, you can filter the specific collection you want to search by just inserting a filter query. So if you want to filter all nodes, you can use this:
cy.nodes(filterQuery);
If you want to filter all elements, just call this:
cy.elements(filterQuery);
If you want to make it easy, you can use this short version (short for cy.filter(...)):
cy.$(filterQuery);
The filter query itself is not that hard, you can do this (assuming that you have a node with the id "first" or an attribute like nodeColor "#2763c4"):
cy.$('[id != "first"]');
cy.$('[id = "first"]');
cy.$('[nodeColor = "#2763c4"]');
cy.$('[weight > 50]');
Additionally, you can specify the target collection within your filter query like this:
cy.$('node[id != "first"]');
Lastly, if you need complex filtering, you can use a function to apply that logic to the filter, for that just do this:
cy.$(function(element, i){
return element.isNode() && element.data('weight') > 50;
});
Sounds like you are trying to cy.filter on a cytoscape instance that no longer exists at that point. That's why it works the first time, but not the second time (after you reinstate the graph, which probably means destroy & create).
You need to make sure you point your filter handlers to the active cytoscape instance.

calling RankToPosition() and _onMoveToPositionClicked

I have a situation where i'd like to enter a "3" into a textbox on a user story grid, call something like RankToPosition(3) to move that user story row to position 3 in the current rank. Within the same grid, the idea is to have a textbox on each row, so the row beneath may have a 4 in there, and when i click SUBMIT, the entire table would be processed by using the numbers in the row textbox and calling RankToPosition(#). This is like the Netflix queue. There have been similar questions on here, but my thought is to just call the underlying method alluded to here as "_onMoveToPositionClicked":
https://help.rallydev.com/apps/2.0rc3/doc/source/MoveToPositionMenuItem.html#Rally-ui-menu-item-MoveToPositionMenuItem-cfg-rankRecordHelper
If i could iterate through the table grid, store initial rank values (i realize they're not just integers), and pick the new text values up, run code to call the _onMoveToPositionClicked beneath the scenes, it may accomplish a bulk rank grid for when users have 200+ items to manage, for instance.
Any insight you have for just calling this in custom code would be helpful. Any solution for representing this functionality would be appreciated. I am currently using Rally 2.0rc3.
Thank you for your time
Is it possible to upgrade to a newer version of the App SDK? 2.0rc3 is a very old pre-release. The latest is 2.1: https://help.rallydev.com/apps/2.1/doc/
In any case, the way ranking is performed is relative to another object via the rankAbove or rankBelow parameters. So given the record you want to rerank:
record.save({
params: {
rankAbove: '/hierarchicalrequirement/12345'
}
});

Yii Nested Set (Yiiext). Trying to move a root node

I am using the fantastic extension by Yiiext "nested-set-behavior":
https://github.com/yiiext/nested-set-behavior
I am interested to know if anyone can let me know how to move (up or down) a root node when I am running the nested set with multiple roots.
tree example:
Phones (root node)
1.1 Mobile
1.2 Fixed
Cars (root node)
2.1 Fast
2.2 Slow
2.3 Average
Planes (root node)
3.1 Large
3.2 Small
At the moment when I pull out the full tree and show this to the user I get the above result.
I would like to be able to move "Cars" before "Phones".
Is there any way of doing this?
I have tried:
$cars = Category::model()->findByPk($cars_id);
$phones = $cars->prev()->find();
$cars->moveBefore($phones);
This gives me an error in the moveAfter method of the nested set behavior class.
Any one done this before?
Thanks
Dave
As the doc suggest the the prev() method returns :
Array of Active Record objects corresponding to ....
Therefore you have to approach this with different way e.g
$phones = Category::model()->findByPk($phones_id);
$cars = Category::model()->findByPk($cars_id);
$cars->moveBefore($phones);
Or other approach which suits your application scenario
Your code could be fixed by :
$cars = Category::model()->findByPk($cars_id);
$phones = $cars->prev()->find();
foreach($phones as $phone){
$cars->moveBefore($phone);
}
which does not make sense ;)
(p.s: did not test this code)
As I understand, you have 3 nodes, which are the roots.
The problem is that the methods moveAfter() and moveBefore() can not be applied to the main roots. You are trying to move a node, relatively another node, but they are in different trees.
If cars and phones have a common root, it will be success.
In other words, you operate with nodes in different trees, which know nothing about each other.