Cookie Consent by Free Privacy Policy Generator 📌 arboles set graph


✅ arboles set graph


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

main

#include <iostream>
#include "graph.hpp"
#include "set.hpp"
#include <fstream>


//stack<int> dfs(graph)



int main() {

srand((unsigned) time(nullptr));

int order = 10;

nodeset U(order);
nodeset V(order);
graph T(order);

for (int i = 1; i <= order; i++) U.ins(i);

  int u = U.select(rand() % U.size() + 1);

  U.del(u);
  V.ins(u);

  while (!U.empty()) {

    int u = U.select(rand() % U.size() + 1);
    int v = V.select(rand() % V.size() + 1);

    T.set(u,v);
    U.del(u);
    V.ins(u);
  }

  T.print();
  T.dot("arbol");
  //graph covertree(T.order());


  return 0;
}

set.cpp

#include "set.hpp"

nodeset::nodeset(int cap): n(cap), s(0){

  r = nullptr;
}

nodeset::~nodeset() {}

void nodeset::ins(int x) {

  assert(!full());

  if (empty()){

    r = new node(x);
    s++;

  }else {

    node *p = r;
    node *q = nullptr;

    while (p and p -> data() != x){

      q = p;

      p = x < p -> data() ? p -> left() : p -> right();
    }

    if (p == nullptr) {

      if (x < q -> data()) q -> left(new node(x));
      else q -> right(new node(x));

      s++;
    }
  }

}

void nodeset::del(int x) {

  cout << "del " << x << endl;
  node *p = r;
  node *q = nullptr;

  while (p && p -> data() !=x) {

    q = p;
    if(x < p -> data()) {
      p = p ->left()
    }
  }
}

void nodeset::print() {

  cout << "[ ";
  order(r);
  cout << "]\n";
}

void nodeset::order(node *p) {
  cout << "order" << endl;
  if (p == nullptr) return;

  order(p -> left());
  order(p -> right());

  cout << p -> data() << " ";

}

void nodeset::order(node *p, int &k, int &n) {

if (p == nullptr or k == 0) return;

  k--;

  if (k == 0) n = p -> data();

  order(p -> left(), k, n);
  order(p -> right(), k, n);
}

int nodeset::select(int k){

  cout << "select" << endl;
  int n;
  order(r,k,n);
  return n;
}

set.hpp

#ifndef set_hpp
#define set_hpp
#include<iostream>
#include<cassert>

using namespace std;

class nodeset{

  class node {

    int _data;

    node *lft;
    node *rgt;

    public:

    node(int x): lft(nullptr), rgt(nullptr) { _data = x; }

    int data() const { return _data; }

    node *left() const { return lft; }
    node *right() const { return rgt; }

    void left(node *p) { lft = p; }
    void right(node *p) { rgt = p; }
  };

  node *r;

int n; //Capacidad
int s; //Tamaño

void order(node *);
void order(node *, int &, int &);


public:

  nodeset(int);
  ~nodeset(int);

  int select(int k);

  void ins(int);
  void del(int);

  int capacity() const { return n; }
  int size() const { return s;}

  bool empty() const { return s == 0; }
  bool full() const { return s == n; }

  void print();
};

#endif /* btree_hpp*/

graph.cpp

#include "graph.hpp"

bool graph::valid(int i, int j){

  assert(0 < i and i <= n);
  assert(0 < j and j <= n);
  //assert(i != j);

  return true;
}

int graph::f(int i, int j) {

  valid(i,j);

  if (i < j) {
    int k = i;
    i = j;
    j = k;
  }

  return (i - 1) * (i - 2) / 2 + j - 1;
}


graph::graph(int ord): n(ord) {

  m = n * (n - 1) / 2;
  T = new bool[m];

  for (int i = 0; i < m; i++) T[i] = false;
}

graph::~graph() {

  delete [ ] T;
}

void graph::set(int i, int j, bool e) {

 valid(i,j);

  if (i != j) T[f(i,j)] = e;
}

bool graph::get(int i, int j) {

  valid(i,j);

  return i == j ? false : T[f(i,j)];
}

void graph::print() {

  for (int i = 1; i <= n; i++) {

    for (int j = 1; j <= n; j++) {

      if (i == j) cout << false << " ";
      else cout << T[f(i,j)] << " ";
    }
    cout << endl;
  }
}

void graph::dot(string fname) {

  ofstream file(fname);

  file << "graph {\n";
  cout << "graph {\n";

  for (int i = 2; i <= n; i++) 
    for (int j = 1; j < i; j++)
      if (T[f(i,j)]){

       file << i << " -- " << j << endl;
       cout << i << " -- " << j << endl;
      }
  file << "}\n";
  cout << "}\n";
}

graph.hpp

#ifndef graph_hpp
#define graph_hpp

#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;

class graph {

int n; // orden del grafo, cantidad de vertices
int m; // tamaño máximo del grafo, cantidad de aristas
//int s; // tamaño del grafo, cantidad de nodos

bool *T;

int f(int, int);

bool valid(int, int);

public:

graph(int);
~graph();

void set(int, int, bool = true); // vamos a quitar depende del get
bool get(int, int); // hay o no hay arista

int order() const { return n; }
//int size() const { return s; }

void print();
void dot(string);
};


#endif /* graph_hpp */
...

✅ arboles set graph


📈 54.42 Punkte

✅ How to create alias for only one half of the command? Like "git graph", where graph="log --all --graph"?


📈 37.61 Punkte

✅ http://www.castillalanueva.gov.co/arboles/fotos/4535674678.jpg


📈 34.75 Punkte

✅ Text to Knowledge Graph Made Easy with Graph Maker


📈 25.07 Punkte

✅ A graph extension written in C: quick and easy deployment of graph model on relational database


📈 25.07 Punkte

✅ CVE-2019-10798 | rdf-graph-array up to 0.3.0-rc6 rdf.Graph.prototype.add privileges management


📈 25.07 Punkte

✅ CVE-2021-41184 | Oracle Big Data Spatial and Graph Big Data Graph cross site scripting


📈 25.07 Punkte

✅ How to Test Graph Quality to Improve Graph Machine Learning Performance


📈 25.07 Punkte

✅ CVE-2021-42340 | Oracle Big Data Spatial and Graph Big Data Graph denial of service


📈 25.07 Punkte

✅ CVE-2020-36518 | Oracle Big Data Spatial and Graph Big Data Graph denial of service


📈 25.07 Punkte

✅ Developer's guide to Microsoft Graph | Learn Together: Building Apps with Microsoft Graph


📈 25.07 Punkte

✅ CVE-2023-46589 | Oracle Big Data Spatial and Graph 3.0.4 Big Data Graph unknown vulnerability


📈 25.07 Punkte

✅ Oracle Big Data Graph up to 2.x Spatial/Graph Remote Code Execution


📈 25.07 Punkte

✅ MISP 2.4.111 event-graph View event-graph.js cross site scripting


📈 25.07 Punkte

✅ Graph-Datenbanken: Graph Query Language soll ISO-Standard werden


📈 25.07 Punkte

✅ CVE-2023-28606 | MISP prior 2.4.169 Event-Graph Node Tooltip js/event-graph.js cross site scripting


📈 25.07 Punkte

✅ Intro to Graph and Native Graph Databases


📈 25.07 Punkte

✅ First Industrywide Graph DB Conference Set for Sept. 28-30


📈 19.67 Punkte

✅ Medium CVE-2020-28276: Deep-set project Deep-set


📈 14.26 Punkte

✅ Google-Set bei Tink: Sicherheit mit Google Nest Cam im 2-Set mit Nest Hub


📈 14.26 Punkte

✅ Medium CVE-2020-7715: Deep-get-set project Deep-get-set


📈 14.26 Punkte

✅ Google-Set bei Tink: Sicherheit mit Google Nest Cam im 2-Set mit Nest Hub


📈 14.26 Punkte

✅ AVM Fritz Mesh Set 7590 + 2400: DSL-Router und Repeater im Set


📈 14.26 Punkte

✅ CVE-2020-7618 | sds up to 3.2.0 js/set.js set input validation


📈 14.26 Punkte











matomo

Datei nicht gefunden!