当前位置: 首页>>代码示例>>C++>>正文


C++ GraphNode类代码示例

本文整理汇总了C++中GraphNode的典型用法代码示例。如果您正苦于以下问题:C++ GraphNode类的具体用法?C++ GraphNode怎么用?C++ GraphNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GraphNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: computeChecklineRequirements

/** Finds which checklines must be visited before driving on this quad
 *  (useful for rescue)
 */
void QuadGraph::computeChecklineRequirements(GraphNode* node,
                                             int latest_checkline)
{
    for (unsigned int n=0; n<node->getNumberOfSuccessors(); n++)
    {
        const int succ_id = node->getSuccessor(n);

        // warp-around
        if (succ_id == 0) break;

        GraphNode* succ = m_all_nodes[succ_id];
        int new_latest_checkline =
            CheckManager::get()->getChecklineTriggering(node->getCenter(),
                                                        succ->getCenter() );
        if(new_latest_checkline==-1)
            new_latest_checkline = latest_checkline;

        /*
        printf("Quad %i : checkline %i\n", succ_id, new_latest_checkline);

        printf("Quad %i :\n", succ_id);
        for (std::set<int>::iterator it = these_checklines.begin();it != these_checklines.end(); it++)
        {
            printf("    Depends on checkline %i\n", *it);
        }
        */

        if (new_latest_checkline != -1)
            succ->setChecklineRequirements(new_latest_checkline);

        computeChecklineRequirements(succ, new_latest_checkline);
    }
}   // computeChecklineRequirements
开发者ID:quantum0813,项目名称:stk-code,代码行数:36,代码来源:quad_graph.cpp

示例2: ERR_FAIL_COND

void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) {

	String prev_name = blend_tree->get_node_name(p_node);
	ERR_FAIL_COND(prev_name == String());
	GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(prev_name));
	ERR_FAIL_COND(!gn);

	String new_name = p_text;

	ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1)

	ERR_FAIL_COND(new_name == prev_name);

	String base_name = new_name;
	int base = 1;
	String name = base_name;
	while (blend_tree->has_node(name)) {
		base++;
		name = base_name + " " + itos(base);
	}

	updating = true;
	undo_redo->create_action("Node Renamed");
	undo_redo->add_do_method(blend_tree.ptr(), "rename_node", prev_name, name);
	undo_redo->add_undo_method(blend_tree.ptr(), "rename_node", name, prev_name);
	undo_redo->add_do_method(this, "_update_graph");
	undo_redo->add_undo_method(this, "_update_graph");
	undo_redo->commit_action();
	updating = false;
	gn->set_name(new_name);
	gn->set_size(gn->get_minimum_size());
}
开发者ID:RandomShaper,项目名称:godot,代码行数:32,代码来源:animation_blend_tree_editor_plugin.cpp

示例3: BuildCFG

/*
 * BuildCFG()
 *  Build one new CFG by cloning the input CFGs and then connecting them. The
 *  original CFG is not changed.
 */
void BuildCFG(CodeInfo *Parent, SuccMap &SMap, Node2Map &NodeMapping,
        int &Version)
{
    GraphNode *ChildCFG;
    
    CloneCFG(Parent->CFG, NodeMapping);

    CodeVec &Successor = SMap[Parent];
    int NumSucc = Successor.size();
    if (NumSucc == 0)
        return;

    for (int i = 0; i < NumSucc; i++)
    {
        CodeInfo *Child = Successor[i];
        if (Child->Version > Version)
            Version = Child->Version;

        if (NodeMapping.count(Child->CFG) == 0)
            BuildCFG(Child, SMap, NodeMapping, Version);
        
        ChildCFG = NodeMapping[Child->CFG];

        NodeVec &Links = Parent->getLink(Child->GuestPC);
        int NumLinks = Links.size();
        for (int j = 0; j < NumLinks; j++)
        {
            if (NodeMapping.find(Links[j]) == NodeMapping.end())
               DM->Error("%s: fatal error on %x.\n", __func__, Child->GuestPC);

            GraphNode *LinkNode = NodeMapping[Links[j]];
            LinkNode->setSuccessor(ChildCFG);
        }
    }
}
开发者ID:wind15973,项目名称:research,代码行数:40,代码来源:llvm-cfg.cpp

示例4: verify_output_socket_satisfied

    void GraphValidator::verify_output_socket_satisfied(const GraphNode &node, const InputSocket& input_socket, ValidationResults &results) const
    {
        auto possible_connection = input_socket.connection();
        if(!possible_connection)
        {
            if(!(node.is_graph_internal_node() && input_socket.optional()))
            {
                std::string text = boost::str(boost::format("Output node %1% is missing an input connection.") % node.display_name());
                results.add(text);
                return;
            }

            if(graph_.get_input_buffer(node.name()))
                return;

            std::string text = boost::str(boost::format("Output node %1% is missing an input connection, or is missing data being set directly on the Graph.") % node.display_name());
            results.add(text);
            return;
        }

        const Connection& connection = possible_connection->get();
        const OutputSocket& output = connection.output();

        if(output.parent() == nullptr)
            throw std::logic_error("Output socket did not have a parent! Internal error!");

        verify_node_satisfied(*output.parent(), results);
    }
开发者ID:SneakyMax,项目名称:NoiseStudio,代码行数:28,代码来源:graph_validator.cpp

示例5: drawnodes

void Graph :: drawnodes(bool treedee, double sz){
	if (treedee) {
		for (int n=0; n< adjlist.size(); n++) {
			
			GraphNode * gn = adjlist.at(n);
			
			vec3d point = gn->getPos();
				
			glPushMatrix();
			glTranslatef(point.x, point.y, point.z);
			glScalef(sz, sz, sz);
			drawsphere (10, 10);
			glPopMatrix();
			
		}
	}
	else 
	{
		
		glPointSize(sz);
		glBegin(GL_POINTS);
		for (int n=0; n< adjlist.size(); n++) 
		{
			GraphNode * gn = adjlist.at(n);
			vec3d point = gn->getPos();
			glVertex3d(point.x, point.y, point.z);
			
		}
		glEnd();
		
		pointsz = sz;
		
	}

}
开发者ID:charlieroberts,项目名称:topicnet,代码行数:35,代码来源:graph.cpp

示例6: normalizeinitpos

void Graph :: normalizeinitpos(){
	//we want to normalize graph node positions between 0.0 and 1.0
	
	double minx=0.0;
	double maxx = 1.0;
	double miny=0.0;
	double maxy = 1.0;

	for (int a=0; a<adjlist.size(); a++) {
		GraphNode * nd = adjlist.at(a);
		vec3d place = nd->getPos();
		
		minx = min(place.x, minx); 
		maxx = max(place.x, maxx); 
		
		miny = min(place.y, miny); 
		maxy = max(place.y, maxy); 
		
	}
	
	//printf("min max %f, %f, %f, %f \n", minx, maxx, miny, maxy);
	
	double yrange = maxy - miny;
	double xrange = maxx - minx;
	
	for (int a=0; a<adjlist.size(); a++) {
		GraphNode * nd = adjlist.at(a);
		vec3d place = nd->getPos();
		place.x = (place.x - minx) / xrange;
		place.y = (place.y - miny) / yrange;
		
		nd -> setPos(place);
		//printf("place of node %f, %f \n", place.x, place.y);
	}
}
开发者ID:charlieroberts,项目名称:topicnet,代码行数:35,代码来源:graph.cpp

示例7: nodesvec

void Graph::move(vec3d amount){
	if (selectednodes.size() > 0) {
		int selectednodeindex = selectednodes.back();
		GraphNode * selected = adjlist.at(selectednodeindex);
		selected->visited(true);
		vector<GraphNode * > level0  = selected-> nodesvec();
	
		 vector < vector< GraphNode* > > visitednodes;
		 visitednodes.push_back(level0);
		 
		 traverse(visitednodes);
		 
		 //printf("size of visitednodes: %d \n", visitednodes.size());
		 //do the actual move
		
		selected -> move(amount);
		for (int v=0; v<visitednodes.size(); v++) {
			amount = amount * 0.4;
			vector<GraphNode * > lv = visitednodes.at(v);
			for (int n=0; n<lv.size(); n++) {
				GraphNode * g = lv.at(n);
				g->move(amount);
			}
		}
		 
		 //unmark all nodes
		for (int a=0; a<adjlist.size(); a++) {
			adjlist.at(a)->visited(false);
		}
		 
	}
	else printf("Graph:move no valid selected node \n");
}
开发者ID:charlieroberts,项目名称:topicnet,代码行数:33,代码来源:graph.cpp

示例8: DEBUG

// addMayEdge
// Adds the edge F -> T with weight Weight.
void IneqGraph::addMayEdge(Value *F, Value *T, APInt Weight) {
  DEBUG(dbgs() << "IneqGraph: addMayEdge: " << *F << " == " << Weight
                << " ==> " << *T << "\n");
  GraphNode *FN = getOrCreateNode(F);
  GraphNode *TN = getOrCreateNode(T);
  FN->addMayEdgeTo(TN, Weight);
}
开发者ID:dtzWill,项目名称:ecosoc,代码行数:9,代码来源:IneqGraph.cpp

示例9: ResetVisited

bool Graph::SearchDFS(GraphNode* start, GraphNode* end)
{
	ResetVisited();

	std::stack<GraphNode*> nodeStack;
	nodeStack.push(start);

	//keep looping until the stack is empty. 
	//This will only happen once we've checked every node. 
	while (!nodeStack.empty())
	{
		//the rest of the algorithm goes in here
		GraphNode* current = nodeStack.top();
		nodeStack.pop();

		if (!current->GetIsVisited())
		{
			current->SetIsVisited(true);

			if (current == end)
			{
				return true;
			}

			for (int i = 0; i < int(current->GetEdgeList().size()); ++i)
			{
				nodeStack.push(current->GetEdgeList()[i]->GetEnd());
			}
		}
		return false;
	}

	return false;
}
开发者ID:PorygonSeizure,项目名称:Complex-Game-Systems,代码行数:34,代码来源:Graph.cpp

示例10: srand

void Graph::inset(long key) {
  srand(time(NULL));
  GraphNode *n = new GraphNode(key);
  nodes[numOfNodes] = n;
  int connectCount = 0;
  int connectSpot;
  int connectedSpot[5];
  bool alreadyConnected = false;
  for(int i = 0; i < 5; i++) connectedSpot[i] = -1;
  if(numOfNodes <= 5) {
    for(int i = 0; i < numOfNodes; i++) {
      nodes[i]->connect(n);
      n->connect(nodes[i]);
    }
  }
  else {
    while(connectCount <= 4) {
      connectSpot = rand() % numOfNodes;
      for(int i = 0; i < connectCount; i++)
        if(connectedSpot[i] == connectSpot) alreadyConnected = true;
      if(!alreadyConnected) {
        nodes[connectSpot]->connect(n);
	n->connect(nodes[connectSpot]);
	connectedSpot[connectCount] = connectSpot;
	connectCount++;
      }
      alreadyConnected = false;
    }
  }
  numOfNodes++;
  if(numOfNodes == capacity) doubleNodes();
  //connect();
}
开发者ID:calebpriester,项目名称:GraphTraversalComparisons,代码行数:33,代码来源:graph.cpp

示例11: StartTimer

void DFS::Solve(GraphNode *startNode, int maxIterations)
{
	StartTimer();
	stack<GraphNode*> nodesStack;

	GraphNode *node = new GraphNode(startNode);
	elements.push_back(node);
	nodesStack.push(node);
	node->visited = true;
	int iterations = 0;
	while (!node->IsSolution())
	{
		node->visited = true;
		node->FindNeighbours(elements);
		node->PushNeighbours(nodesStack);
		node = nodesStack.top();
		while ((node = nodesStack.top())->visited)
		{
			nodesStack.pop();
		}
		iterations++;
		if (iterations > maxIterations)
		{
			ShowResult(false, iterations);
			StopTimer();
			return;
		}
	}
	StopTimer();
	ShowResult(true, iterations, node);
}
开发者ID:kirkor93,项目名称:15,代码行数:31,代码来源:DFS.cpp

示例12: Dijkstra

DoubleLinkedList<GraphNode *> Dijkstra(GraphNode *Start, GraphNode * End)
{
	Map<GraphNode *, DijkstraHelperNode *> NodeHelperMap;
	DoubleLinkedList<DijkstraHelperNode *> Visited;
	MinHeap<DijkstraHelperNode *> OpenHeap;
	DijkstraHelperNode *NewHelper = new DijkstraHelperNode();
	NewHelper->m_Node = Start;
	NewHelper->m_Cost = 0;
	NodeHelperMap.Insert(Start, NewHelper);
	OpenHeap.Insert(NewHelper);
	while(!OpenHeap.IsEmpty())
	{
		DijkstraHelperNode *CurrentHelperNode = OpenHeap.PopTop();
		assert(CurrentHelperNode != NULL);
		GraphNode *CurrentGraphNode = CurrentHelperNode->m_Node;
		assert(CurrentGraphNode != NULL);
		DoubleLinkedList<GraphEdge *> *CurrendEdges = CurrentGraphNode->GetEdges();
		DoubleListNode<GraphEdge *> *CurrentEdge = CurrentEdges.GetHead();
		while(CurrentEdge != NULL)
		{
			GraphNode *OtherNode = CurrentEdge->m_End;
			if(OtherNode == CurrentGraphNode)
			{
				OtherNode = CurrentEdge->m_Start;
			}
			assert(OtherNode != CurrentGraphNode);
			DijkstraHelperNode *NodeHelper = NodeHelperMap.GetValue(OtherNode);
			if(NodeHelper == NULL)
			{
 				NodeHelper = new DijkstraHelperNode();
				NodeHelper->m_Node = OtherNode;
				NodeHelperMap.Insert(OtherNode, NodeHelper);		
				OpenHeap.Insert(NodeHelper);
			}
			int CostToNode = CurrentHelperNode->m_Cost + CurrentEdge->m_Cost;
			if(CostToNode < NodeHelper->m_Cost)
			{		
				NodeHelper->m_Cost = CostToNode;
				NodeHelper->m_Previous = CurrentGraphNode;
				OpenHeap.Update(NodeHelper);
			}
			if(OtherNode == End)
			{
				break;
			}
		}
	}

	DoubleLinkedList<GraphNode *> Path;
	DijkstraHelperNode *EndHelper = NodeHelperMap.GetValue(End);
	if(EndHelper != NULL)
	{
		DijkstraHelperNode *CurrentHelper = EndHelper;
		while(CurrentHelper != NULL)
		{
			Path.AddFront(CurrentHelper->m_Node);
			CurrentHelper = CurrentHelper->m_Previous;
		}
	}
}
开发者ID:frods,项目名称:codebase,代码行数:60,代码来源:dijkstra.cpp

示例13: printAdjacentNodes

void GraphNode :: printAdjacentNodes(){
	for (int a =0; a< adjacents.size(); a++){
		GraphNode * tmp = adjacents.at(a);
		printf("neighbors %i 'th id is: %i \n", a, tmp->getnodeid());
	}
	
	
}
开发者ID:charlieroberts,项目名称:topicnet,代码行数:8,代码来源:graphNode.cpp

示例14: remove_child_notify

void GraphEdit::remove_child_notify(Node *p_child) {

	top_layer->call_deferred("raise"); //top layer always on top!
	GraphNode *gn = p_child->cast_to<GraphNode>();
	if (gn) {
		gn->disconnect("offset_changed",this,"_graph_node_moved");
		gn->disconnect("raise_request",this,"_graph_node_raised");
	}
}
开发者ID:Scrik,项目名称:godot,代码行数:9,代码来源:graph_edit.cpp

示例15: addEdge

 void addEdge(int A, int B) {
     GraphNode *tmp;
     tmp = new GraphNode(B);
     tmp->setNext(list[A]);
     list[A] = tmp; 
     tmp = new GraphNode(A);
     tmp->setNext(list[B]);
     list[B] = tmp;
 }
开发者ID:coolis,项目名称:Algorithms,代码行数:9,代码来源:graph.cpp


注:本文中的GraphNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。