Defining bonds without data file

I have interest in defining bonds without using a data file, is there any way to do this in the input script? Or by using the LAMMPS C++ library? I was thinking something along the lines of

atom->data_bonds(nchunk, buffer, count, id_offset, boffset);

I don’t want to read a data file into the buffer though.

I have interest in defining bonds without using a data file, is there any
way to do this in the input script? Or by using the LAMMPS C++ library? I
was thinking something along the lines of

atom->data_bonds(nchunk, buffer, count, id_offset, boffset);

i strongly advise against (ab)using functionality, that LAMMPS uses
internally for a specific purposes and that require other steps to be
performed ahead of calling them in a specific way.

I don't want to read a data file into the buffer though.

there is a big conceptual problem with any of this. the basic
architecture of LAMMPS requires that you reserve suitable space for
storing information about bonds (and angles/dihedrals/etc.) as well as
exclusions ahead of time when defining the system cell. that space
cannot be changed after that. using a data file makes this process
straightforward and simple, at least from the user perspective. data
files are scanned twice to determine what information is present and
how much space is needed and then allocate and fill the storage.

you *can* define bonds after the fact, see for example the
"create_bonds" command (or fix bond/create).

create_bonds uses pairwise distances and by traversing neighbor list
to collect a list of bonds and then defines them.
if you have a different set of "rules" how you determine what bonds
you want to define, i would suggest you create a custom command style
for this.
please keep in mind, that there are certain requirements, how
information of bonds is stored and that also after adding bonds,
information that is dependent on bonds needs to be recreated (e.g.
exclusions). things are even more complex, if also angles/dihedrals
are to be created based on the changes in the bond topology.

please also keep in mind, that bond information is stored in a
distributed fashion and that when running in parallel, you have to
make certain, all MPI ranks follow the same code path, that changed
information is properly communicated across MPI ranks, that you take
into account the differences between "newton on/off" settings (i.e.
how bonds are stored and computed when the two participating atom of a
bond are "owned" by different MPI ranks) and that overall everything
remains consistent.

axel.