.getEdges() problem

Extensions and customization
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
yxj0312
Posts:3
Joined:22 Mar 2013 18:42
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
.getEdges() problem

Post by yxj0312 » 10 Apr 2013 13:42

Hi,
i wrote a Programm to calculate the connected edge with a specifial formel,and put the result into "Weight" Column of Edge.

to set the value,i used a for-code like

Code: Select all

 for(Node m : graph.getNeighbors(n))
{...
 edge.getEdgeData().getAttributes().setValue("Weight", result);}
it runs well.


because i will use those result later and need to avoid the NullPointerException. i wrote some method to fill all the Edge´s Weight

fisrt i put all the connected edges into a Arraylist then wrote a "hasedge" method

Code: Select all

public boolean hasEdge(Edge edge) {
        
        for(Edge e: connectedEdges) {
            if(edge.equals(e)) {
                return true;
            }
        }
        return false;     
    }
and i wanna fill all the rest value with Float.infinity

Code: Select all

public void fill(Graph graph){
        for(Edge n :this.graph.getEdges().toArray()) {
           
                if(!hasEdge(n)) {
                  n.getAttributes().setValue("Weight", Float.POSITIVE_INFINITY);

              
            } 
but i only got all the value as infinity including the connected edges.

it seems that, the edge from .getedges() are all the edges,including the whole path.

any suggestion?

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable